Skip to content

useIntersectionObserver does not handle state correctly when target element is changed #1616

@mortyccp

Description

@mortyccp

Prior Issues

No

What is the current behavior?

useIntersectionObserver state is not reset when target element is changed, like if target is changed to null, the intersection state still report the pervious value

Steps to Reproduce

  1. use useIntersectionObserver to observe an element and create a button to set the target to null afterwards

What is the expected behavior?

  1. should handle state when the target of any other options pass to the hooks is changed

Environment Details

  • _@react-hookz/web version: 23.1.0
  • _react version: 18.3.3
  • _react-dom version: 19.0.0
  • _typescript version: 5.7.3
  • _OS: Mac
  • _Browser: Chrome
  • _Did this work in previous versions? No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions