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
(React) Title and other metadata are not unset when component unmounts #558
The app is initially rendering the <Page2> element, which does not set any <meta> tags.
Observe the <head> of the rendered app. Observe that the title tag is set to the fallback title "Example fallback" and there is a description <meta> tag with content "some description" as configured in the init parameter of the createHead function. (Expected)
Click the button labeled "Page 1" to mount the <Page1> component. Observe that the title and description are updated based on the values set in the useHead hook in the <Page1> component. (Expected).
Click the button "Page 2" to unmount the <Page1> component and remount the <Page2> component.
Observe that the meta tags are still displaying the Page1 values, even though the <Page1> component was unmounted. (Unexpected behavior)
Expected behavior:
The <meta> values configured by the <Page1> component are removed when the component is unmounted, and the values from the init parameter of the createHead function are added again.
Describe the bug
When a component unmounts, it doesn't unset <meta> tags that were configured in that component, nor are the <meta> tags reset to the values in the init parameter of the createHead function.
Additional context
I'm new to this library, so I might be completely misunderstanding the expected behavior here. Thanks for your help!
Activity
harlan-zw commentedon Jul 6, 2025
Thanks for this detailed issue. This was an Unhead bug, I've pushed up a fix in v2.0.12 which looks to fix it here https://stackblitz.com/edit/vitejs-vite-nqsjcyrq?file=package.json
LMK if you have any other ikssues
petrovmiroslav commentedon Feb 17, 2026
sorry guys, but the issue's still there in React 18. https://stackblitz.com/edit/vitejs-vite-ssp6wmnr?file=src%2FApp.tsx
fix(react): dispose head entries on unmount in React 18 StrictMode
fix(react): dispose head entries on unmount in React 18 StrictMode
fix(react): dispose head entries on unmount in React 18 StrictMode
fix(react): dispose head entries on unmount in React 18 StrictMode (#664
harlan-zw commentedon Feb 24, 2026
Thanks @petrovmiroslav