I created a library that simplifies working with Context, and won't rerender the whole app when a Provider rerenders from a state change. https://github.com/baron816/galactic-context
Nice! Seems more "raw context" than most of the simple state management libraries I've seen so far!
I also created a library for state management including Context, the main goal as well was not to rerender everything when a fragment of a Context changes (which is IMHO the main limitation of using Context):
So, I didn’t get a chance to post this last night due to being rate limited, but I’ll post it today due to my conviction that Dan Abaramov is dangerous to the JavaScript community:
I appreciate the effort and technical prowess involved, but quite frankly Redux is bad design to begin with. Dan Abramov is a smart guy but does not think clearly enough to be allowed to design APIs.
Not saying MobX or the like are any better, but we need clearer heads approaching this problem with solutions that border on one-liners. We are storing some stuff in a global for Christ sakes, can’t we simplify all of this out of the reducer/observer pattern?
I’m depressed the marketplace of ideas has not jettisoned Dan Abramov’s ideas (the reducer pattern ended up in core React).
To me, actions is the insight in the reducer approach popular in React community. Actions and reducers force you to clearly define the logic of what can happen in a way that keeps it decoupled from the UI or some global state. When used properly, this actually helps arrive at a better and more sustainable design overall.
I’m working on a somewhat complex app and for a long time was sticking to plain useState and contexts, and lately I’m finding that moving it to a reducer (plain React, no Redux) has positive effects on architecture.
That said, the devil’s in the details—I personally think the approach is sometimes misused, including sadly certain tutorial materials. I’m reasonably new to reducers though.
Not sure that this has it quite right, but something along these lines (redux-like, but integrated with immer seems like a good idea). Perhaps it could also could also use TypeScript to cut down on "action creator" boilerplate?
I've been using pullstate as a Redux alternative, found it to be way more ergonomic. Uses immer for updates, and the move away from action-creators, actions, reducers, etc. cuts down on a huge amount of boilerplate, as well as making it more type-safe when using Typescript.
without a provider you cannot run many instances of the same store in the same App. (that's how I can run 3 times the same App in my demo https://taverne.uralys.com/demo)
zustand inspired me a lot to create the custom hooks for La Taverne, and you can also create your {store, dispatch} to use anywhere without React (and providers)
baron816|5 years ago
You can play around with a demo here https://codesandbox.io/s/galactic-context-demo-eqkrp
franciscop|5 years ago
I also created a library for state management including Context, the main goal as well was not to rerender everything when a fragment of a Context changes (which is IMHO the main limitation of using Context):
https://statux.dev/
There's probably dozens like ours! It's fun, simplifies and improves development and it's not so heavy-handed as Redux (+ all the concepts behind).runawaybottle|5 years ago
I appreciate the effort and technical prowess involved, but quite frankly Redux is bad design to begin with. Dan Abramov is a smart guy but does not think clearly enough to be allowed to design APIs.
Not saying MobX or the like are any better, but we need clearer heads approaching this problem with solutions that border on one-liners. We are storing some stuff in a global for Christ sakes, can’t we simplify all of this out of the reducer/observer pattern?
I’m depressed the marketplace of ideas has not jettisoned Dan Abramov’s ideas (the reducer pattern ended up in core React).
We are all better than this.
strogonoff|5 years ago
I’m working on a somewhat complex app and for a long time was sticking to plain useState and contexts, and lately I’m finding that moving it to a reducer (plain React, no Redux) has positive effects on architecture.
That said, the devil’s in the details—I personally think the approach is sometimes misused, including sadly certain tutorial materials. I’m reasonably new to reducers though.
nicoburns|5 years ago
MBCook|5 years ago
cercatrova|5 years ago
marcusbuffett|5 years ago
mosdl|5 years ago
ManuelHeL|5 years ago
chrisdugne|5 years ago
zustand inspired me a lot to create the custom hooks for La Taverne, and you can also create your {store, dispatch} to use anywhere without React (and providers)
chrisdugne|5 years ago
The goal is to keep Redux original power and simplicity, removing the headaches of addons like Redux-thunks or Reselect.
avaldeso|5 years ago