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
{{ message }}
Repository navigation
bug(react-native): useAskableVisibility and useAskableScrollView leak context when ctx prop changes #250
Both useAskableVisibility and useAskableScrollView create an internal context via useState when no ctx is provided. The cleanup effect is supposed to destroy that internal context on unmount — but the cleanup condition checks the options parameterctx, not the state variable, causing it to always run (or never run) incorrectly if the parent later provides a different context.
const[visibilityCtx]=useState<AskableContext>(()=>ctx??createAskableContext(options));useEffect(()=>{return()=>{if(!ctx){// ← checks the CURRENT options.ctx propvisibilityCtx.destroy();// ← but visibilityCtx was created based on ctx at mount time}};},[ctx,visibilityCtx]);
If a parent passes ctx={undefined} at mount (so an internal context is created) and later passes ctx={someCtx}, the cleanup will NOT destroy the original internal context because at cleanup time ctx is now truthy.
The identical pattern exists in useAskableScrollView.ts.
Expected behavior
Whether to destroy the internal context should be decided at creation time (was a context created internally?) and stored alongside it, not re-evaluated at cleanup time from the current prop value.
Activity
fix: audit fixes for sanitizer leaks, context cleanup, and listener t…