Closed jacargentina closed 2 years ago
SOLVED
The server-side rendered MDX , even if having a Context Provider and child like this:
<AppProvider>
<Demo />
</AppProvider>
...Will not be the same context provider as on client side, when <Demo/>
is mounted via getMDXComponent
Solution: the AppProvider does this.
So <Demo/>
(in my case I need two utility functions that interact to show a modal on the page) can access them via window
globally
Hey @jacargentina, did you ever find a better way to solve this issue?
I'm encountering something similar when using styled-components
that reference a theme context and don't think it can be solved by exposing the theme globally unless we also change all the references to that theme.
https://github.com/jacargentina/remix-mdx-test
@kentcdodds as promised, here is the demo for the
useContext
problem, as I pointed on discord today.Cheers!
UPDATE: added a commit with a hackish? way to solve it. I hope there is a better approach?