fix(react): dispose head entries on unmount in React 18 StrictMode#664
Merged
fix(react): dispose head entries on unmount in React 18 StrictMode#664
Conversation
Contributor
Bundle Size Analysis
|
8b5f06e to
81b9f10
Compare
Moves entry creation from render-time (useRef init) into useEffect to avoid orphaned entries caused by React 18 StrictMode resetting refs between double-render invocations. Returns a stable proxy so callers get a consistent reference before the effect runs. Closes #558
81b9f10 to
7ea7bd5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π Linked issue
Resolves #558
β Type of change
π Description
React 18 StrictMode resets
useRefbetween its double-render invocations, causing head entries created during render to become orphaned β they never get disposed on unmount. This moves entry creation intouseEffectand returns a stable proxy, ensuring entries are properly cleaned up when components unmount. Adds 4 regression tests covering the exact reproduction from #558.