-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
The progressive hydration strategy doesn't work well with react context, exactly in this scenario:
- Providing some context value on the top of the app.
- Consuming a context inside the children that is hydrated with the ProgressiveHydration component.
const Context = createContext()
function Content() {
const value = useContext(Context)
const [status, setStatus] = useState('not hydrated yet')
useEffect(() => setStatus('hydrated'), [])
return `status: ${status} - context value: ${value}`
}
function App() {
return (
<Context.Provider value="example">
<ProgressiveHydration>
<Content />
</ProgressiveHydration>
</Context.Provider>
)
}
Result:
The context value is undefined
after the rehydration...
Before hydration: status: not hydrated yet - context value: example
After hydration: status: hydrated - context value: undefined
I'm not sure if this can be solved in an easy way or there is some limitation on this strategy. Any idea @midudev ?
Metadata
Metadata
Assignees
Labels
No labels