News for hackers. Stuff that matters.
Re:Recoil – A state management library for React by davidmccabe on Thursday May 14, 2020 @02:10PM (#23183177)
Well, I know that on one tool we saw a 20x or so speedup compared to using Redux. This is because Redux is O(n) in that it has to ask each connected component whether it needs to re-render, whereas we can be O(1).

useReducer is equivalent to useState in that it works on a particular component and all of its descendants, rather than being orthogonal to the React tree.

I think if you can model something with pure functions, you should. That's the approach we try to take for asynchronous processes: just a pure function that you happen to evaluate on some other process. This obviates the need for things like sagas. So I agree with you there I guess.

If you post an example of what you don't think it could handle I will tell you how we would handle it.

Re:Recoil – A state management library for React by weeksie on Thursday May 14, 2020 @02:14PM (#23183230)
I've never had my bottlenecks end up being because of Redux, but that could just be me.

I'd love to take a look at a larger project using Recoil though, just to get a sense for how it looks with a relatively complex state setup. My first impression is that it would get messy pretty quick, but I've been wrong many times before :)

Also, I'm not trying to shit all over your project, congrats on rethinking state management. Regardless of how I feel about your library, that's still awesome.

Re:Recoil – A state management library for React by davidmccabe on Thursday May 14, 2020 @02:16PM (#23183259)
The app in question had thousands of connected components, so that was a huge bottleneck for them. For many apps it doesn't matter.

The app that Recoil was originally extracted from has an extremely complex set of state and interdependent derived processes -- also heavily hooked into and modified by third-party plugins. This type of complexity is exactly what Recoil was designed to handle.

Thanks for your kind words.

Re:Recoil – A state management library for React by weeksie on Thursday May 14, 2020 @02:28PM (#23183396)
That's awesome. Best of luck going forward!
Re:Recoil – A state management library for React by city41 on Thursday May 14, 2020 @03:24PM (#23184164)
You can hoist useReducer out to context and end up with essentially a very lightweight redux. I’ve had some success with that in smaller apps. For something large or long term I’d probably avoid that approach though.
Re:Recoil – A state management library for React by diffrinse on Thursday May 14, 2020 @07:02PM (#23186667)
>Well, I know that on one tool we saw a 20x or so speedup compared to using Redux. This is because Redux is O(n) in that it has to ask each connected component whether it needs to re-render, whereas we can be O(1).

Don't I get the same perf with selectors?

Re:Recoil – A state management library for React by davidmccabe on Friday May 15, 2020 @02:15PM (#23195439)
I could be mistaken but I think that you still have to do a shallow compare on the connected props of every component.
Re:Recoil – A state management library for React by diffrinse on Friday May 15, 2020 @04:19PM (#23196928)
Nah, you're completely correct