The usePresence hook provides a safeToRemove callback. However, if the parent re-renders during the exit animation and I add safeToRemove to the useEffect dependency array, the function is recreated, causing the effect to trigger unnecessarily.
This happens despite #2431 wrapping the callback with the useCallback hook.
After looking into it, I found that the onExitComplete function in PresenceContext is being recreated unnecessarily. Take a look at the PR I'll be submitting.
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
1. Read the FAQs 👇
✅
2. Describe the bug
The
usePresence
hook provides asafeToRemove
callback. However, if the parent re-renders during the exit animation and I addsafeToRemove
to theuseEffect
dependency array, the function is recreated, causing the effect to trigger unnecessarily.This happens despite #2431 wrapping the callback with the
useCallback
hook.After looking into it, I found that the
onExitComplete
function inPresenceContext
is being recreated unnecessarily. Take a look at the PR I'll be submitting.3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://codesandbox.io/p/sandbox/safetoremove-re-create-issue-nzvmfy
4. Steps to reproduce
Steps to reproduce the behavior:
5. Expected behavior
The
safeToRemove
function should remain the same, regardless of whether the parent is re-rendered or not.