React-central-state is an easy-to-use React library created to help you share a common state between your components without passing state to props...
For further actions, you may consider blocking this person and/or reporting abuse
The critical difference is: With Redux, i don't need React to describe my application state, React is just the view layer, i could go with vanilla JS or jQuery with Redux.
So this solution is too framework-coupling, so it's not good, or unusable to me.
Hey. Newbie here.
What's the difference of this library from React Context API? TIA
Hi,
-The Context API lets you create a relationship between one data provider and multiple data consumers.
-Central State kicks the state out of all react components and lets them read and change its properties.
-With Context, either you create a new container for each shared property, or you wrap all properties on the context object. -> But then be ready for a lot useless re-rendering.
-Central State dispatched updates on subscribed properties changing, not the whole state, and also gives you control over them on shouldcomponentupdate().
-With only React Context, if you need to change a state property inside a consumer component, you'll have to define a new function embedded in the context itself.
This may have the advantage of isolating concerns like mutating the state -making it easier to debug- but it also gives you lot of extra work.
Well that's my view on it, at least.
But I like this library mostly because of its simplicity.
Thanks, came in here to ask this.
that answer demystified it for me! thanks! I'm surely gonna try this out in smaller projects, that don't need redux & redux-saga or Apollo, etc
I was using Redux so far amd it always worked, but I find this solution interesting. Sometimes reducers and action creators are too much hassle. I will give this a try at least for a smaller project
Nice, it's an easier approach than redux