4 ms·
I'm still confused. They present an example where they load data from local storage but do not make it clear how that data is passed out to the app. What if I'
by CSSer 4y ago
I'm still confused. They present an example where they load data from local storage but do not make it clear how that data is passed out to the app.
What if I'd like to always initialize my app's state with the data in local storage? Let's say I want to initialize from localStorage and pass this to context. Doing so triggers a hydration error in React v18 because the server-side value will never match the hydrated value once set. It seems like a job for useSyncExternalStore since that's what localStorage is (an external key-value store), but the ergonomics of the subscribe function seem odd to me.