You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
custardcream98
changed the title
[BUG] onExitComplete funciton in PresenceContext is being unnecessarily recreated
[BUG] safeToRemove Callback Recreated on Parent Re-render
Sep 14, 2024
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.The text was updated successfully, but these errors were encountered: