Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(react): dispose head entries on unmount in React 18 StrictMode#664

Merged
harlan-zw merged 1 commit intomainfrom
fix/react-18-unmount-cleanup
Feb 24, 2026
Merged

fix(react): dispose head entries on unmount in React 18 StrictMode#664
harlan-zw merged 1 commit intomainfrom
fix/react-18-unmount-cleanup

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Feb 24, 2026

πŸ”— Linked issue

Resolves #558

❓ Type of change

  • πŸ“– Documentation
  • 🐞 Bug fix
  • πŸ‘Œ Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

πŸ“š Description

React 18 StrictMode resets useRef between its double-render invocations, causing head entries created during render to become orphaned β€” they never get disposed on unmount. This moves entry creation into useEffect and returns a stable proxy, ensuring entries are properly cleaned up when components unmount. Adds 4 regression tests covering the exact reproduction from #558.

@github-actions
Copy link
Contributor

Bundle Size Analysis

Bundle Size Gzipped
Client (Minimal) 11.4 kB 4.7 kB
Server (Minimal) 10.3 kB 4.2 kB
Vue Client (Minimal) 12.3 kB 5.1 kB
Vue Server (Minimal) 11.1 kB 4.6 kB

@harlan-zw harlan-zw force-pushed the fix/react-18-unmount-cleanup branch from 8b5f06e to 81b9f10 Compare February 24, 2026 14:13
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
@harlan-zw harlan-zw force-pushed the fix/react-18-unmount-cleanup branch from 81b9f10 to 7ea7bd5 Compare February 24, 2026 14:20
@harlan-zw harlan-zw merged commit 50ffe37 into main Feb 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(React) Title and other metadata are not unset when component unmounts

1 participant