DEV Community

Discussion on: React Context without Provider + useMutableSource

Collapse
 
aslemammad profile image
Mohammad Bagher Abiyat

Thank you, Fang, you made my day. Yes, you can use this approach, And I use it in my projects. Or you can use the better version of it, which we work on, jotai.
github.com/pmndrs/jotai

The store lives in a simple object, but we attach some useStates to it basically when we use uMS, so when it changes, we call those useStates(setStates) in the components. So no wasteful renders like React Context. Just your subscribed component is going to be changed.

github.com/reactjs/rfcs/blob/maste...
github.com/reactwg/react-18/discus...

Collapse
 
windmaomao profile image
Fang Jin

thanks for the quick reply man, i actually came from the RFC page :)

will take a close look at article you forwarded and jotai. Always interested at some localized version of redux. Thank you.

Thread Thread
 
aslemammad profile image
Mohammad Bagher Abiyat

Yes, I appreciate it. I recommend you take a look at the simulated version which I gave the link in the article. It's a good alternative to the experimental one.