-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
If I understand intent correctly, observer should watch only for one node at a time, unobserving previous node if refCallback is re-invoked:
Lines 59 to 62 in dcdd47c
| if (node) { | |
| observer?.unobserve(node); | |
| setEntry(undefined); | |
| } |
But refCallback updates node reference before invoking reinitializeObserver:
Lines 94 to 99 in dcdd47c
| nodeRef.current = node; | |
| reinitializeObserver(); | |
| return () => { | |
| nodeRef.current = null; | |
| reinitializeObserver(); |
So unobserve just never ever is called.
Demo: https://codesandbox.io/p/sandbox/s7mwhj
Check out console output. See how it logs visibility changes for all nodes, despite the fact same refCallback is used for all them – so only the last one should be observed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels