-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always execute the <Metadata> component on the client #10271
Conversation
Otherwise throws a TypeError when serving the site, `React.createContext is not a function`
Actually trying this code I get an error like
It's interesting that it says that it's not exported, because looking at the file I clearly see this I suspect, but have not been able to verify yet, that this is a CJS vs ESM issue |
Yep I saw that same thing after adding |
Looking into this a bit more, it actually does look like it's us that are using context. Or, maybe the real solution is to have two versions of |
With all the other changes that have happened since this PR was opened this now works! And putting |
If React 19 can move |
…into feat/location-serverStore * 'feat/location-serverStore' of github.com:dac09/redwood: no need to repeat fullUrl Use Replay for smoke tests (redwoodjs#10664) chore(testing): Remove unused member in Props interface (redwoodjs#10699) fix(cli): Directive generator command was not creating files (redwoodjs#10698) Always execute the <Metadata> component on the client (redwoodjs#10271)
Right now in an RSC app if you use
<Metadata>
in a page or other component rendered on the server, the serve process dies with the error:Tobbe suggested that something in
<Metadata>
or possiblyHelmet
is doingcreateContext
internally, an so all of this code can only run on the client. The solution is to simply add'use client'
to the top of theMetadata.ts
file.