Sharing hook state using useSWR - useSharedState #1288
Unanswered
timcouchoud
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Since I would like to avoid using Redux or other state manager, I am trying to implement the state sharing strategy (using useSWR) published by @pacocoursey (▲) is his article I am trying to implement it but I struggle in undertanding how I can catch the state from one component to the other since it takes the initialData (using useSharedState) for which I do not want to give a value. I just want to pull the state from one component to one other without giving an initial value. Any idea about that?
Here is the situation:
Component A: using getServerSideProps to inject it in useSharedState
const [user, setUser] = useSharedState("connectedUser", props.user);
Component B: here I am trying to "pull" user value but I do not know what to put as initialData ("?????")
const [user, setUser] = useSharedState("connectedUser", ???????);
Beta Was this translation helpful? Give feedback.
All reactions