-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
Loaded virtual module is unable to access parent react context #17492
Loaded virtual module is unable to access parent react context #17492
Comments
This is an expected behavior. It's important to note that you have
You might need to rework architecture so that |
That explains the behaviour, it felt like the component imported was separated from my app. Thank you very much @hi-ogawa for the explanation and providing a fix. |
Describe the bug
I'm not fully sure if this is a bug or is how it works.
I have a react tree with a context on top:
The
App
is an export from a virtual module:But when I try to access the context, I get an error because is reset to null:
Reproduction
https://github.com/Neo-Ciber94/vite-ssr-react-context-issue
Steps to reproduce
yarn install
andyarn dev
System Info
Used Package Manager
yarn
Logs
Error: "ThemeContext" was not available
at Module.useTheme (.../src/context.tsx:10:11)
at App (virtual:app:8:39)
Validations
The text was updated successfully, but these errors were encountered: