I have a static page with two components.
- One in the header that shows a menu handling user preferences/login and signup
- One in the main page that is able to display a list of user images or a form about the user profile for instance.
Is there a way to share a state (let say the access_token to the API for instance) between those two components?
I could add ports to each components that would update a localStorage key and send the store to each other components.
But is there a better way for this?
The solution I ended-up with was to use two ports:
With decoders and encoders:
And then I use them to sync my component store and keep a copy on the localStorage: