Live data from Hacker News

Recoil – A state management library for React

recoiljs.org

31–40 of 83 posts

Re: Recoil – A state management library for React

#31
post #3

I'm not seeing how this works with more complex state flows. Doesn't seem much better than useReducer. Frankly, for state management I still haven't found anything that beats Redux on its own without thunks or sagas or any of that bullshit. This is despite doing my level best to see if useReducer on its own would be sufficient. It's not. Thunks are unmaintainable. Sagas are put together with bailing twine and rely to…

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 funct…

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

#32
post #3

I'm not seeing how this works with more complex state flows. Doesn't seem much better than useReducer. Frankly, for state management I still haven't found anything that beats Redux on its own without thunks or sagas or any of that bullshit. This is despite doing my level best to see if useReducer on its own would be sufficient. It's not. Thunks are unmaintainable. Sagas are put together with bailing twine and rely to…

Having worked many years on mid to large scale React apps, I must say: In most cases component state (or useSate) and context works just fine. Why is everyone so eager to add third party state libraries from the getgo? In most projects, Redux doesn't add net value.

I've been working with React since 2014 and I've never had a good experience with an app that relied entirely on component state. To each their own, perhaps you've discovered something I haven't.

For me, Redux works very well with how I think about control flow. That said, my brain has been ruined by a youth misspent in fp land, so my preferences should be taken with a liberal application of salt.

Re: Recoil – A state management library for React

#34
post #3

I'm not seeing how this works with more complex state flows. Doesn't seem much better than useReducer. Frankly, for state management I still haven't found anything that beats Redux on its own without thunks or sagas or any of that bullshit. This is despite doing my level best to see if useReducer on its own would be sufficient. It's not. Thunks are unmaintainable. Sagas are put together with bailing twine and rely to…

For complex state flows we use Kea JS. https://kea.js.org/

The library has been around for a while and reduces a lot of boilerplate.

Is also used by some quite big names.

Re: Recoil – A state management library for React

#35

Earlier quoted context omitted.

Don't have experience with ASP or JSP, but managing state in React is vastly superior than iOS. Having a defined place to keep your data, and your view automatically refresh when it changes is the gold standard in user interface design. iOS does not easily have this kind of functionality, forcing people to use all sorts of messy techniques that are hard to follow and maintain. The main "Apple approved" tools for user…

> Having a defined place to keep your data, and your view automatically refresh when it changes is the gold standard in user interface design. First, in most frameworks there is only one place to keep your data. This can be your App object or session state. Having view automatically refresh is overrated. Given the amount of work you have to do (actions, reducers, dispatch and whatnot) it is easier to just update the…

You don't need any of that if you just use React. All you need is `setState()`. All of those extra things you are thinking about are part of Redux, not React. I love Redux, but even just pure React is a huge improvement over UIKit.

UIKit kind of reminds me of Backbone.js - it has some infrastructure but its up to you to build a lot of the tools yourself. You might prefer that personally, but I think the movement of the frontend community from Backbone to React shows that most developers prefer a more full feature solution.

Re: Recoil – A state management library for React

#37

What is it about React that state management is such a such a hassle? This is not the case in other frameworks. Consider iOS for example. Just add fields in App and you're done: https://developer.apple.com/documentation/swift/maintaining_... Similarly in ASP.NET: https://docs.microsoft.com/en-us/previous-versions/aspnet/75... Same in JSP: https://javabeginnerstutorial.com/jsp-tutorial/state-managem... But in React it…

Its a huge issue in all of those also. It just presents itself differently. JSP -- every click has to post or query param change re-renders the page. This gets hugely cumbersum with tree stateor anything other than basic switches. In a lot of ways its the one way data flow we all want in react. For a lot of pages its easy. Same with React, However complex state is so difficult to do in JSP you really can't write the apps we write today.

I would say React's state management is its great success, rather than its `functionalness` or its reactivity. No other UI framework (QT|WinForms|MOTIF|GTK) really ever handled state well.

Re: Recoil – A state management library for React

#39

What is it about React that state management is such a such a hassle? This is not the case in other frameworks. Consider iOS for example. Just add fields in App and you're done: https://developer.apple.com/documentation/swift/maintaining_... Similarly in ASP.NET: https://docs.microsoft.com/en-us/previous-versions/aspnet/75... Same in JSP: https://javabeginnerstutorial.com/jsp-tutorial/state-managem... But in React it…

React has fantastic tools for state management built-in. The difficulty is a particular flavor of state management: data that lives in the "global" scope but can be used locally in components in a reactive fashion. We have some good tools for doing this but they all have drawbacks, hence the experimentation.

FWIW I've never seen a really great solution for this in any JavaScript framework. I read it as a sign of React's maturity that this is a focus.

Re: Recoil – A state management library for React

#40

What is it about React that state management is such a such a hassle? This is not the case in other frameworks. Consider iOS for example. Just add fields in App and you're done: https://developer.apple.com/documentation/swift/maintaining_... Similarly in ASP.NET: https://docs.microsoft.com/en-us/previous-versions/aspnet/75... Same in JSP: https://javabeginnerstutorial.com/jsp-tutorial/state-managem... But in React it…

React is not a complete framework more of a templating engine and nothing more, it allows you to use any state management you want. It also makes it easy to add to existing projects without requiring rewrite of everything from the ground up.

The downside of this is that it's often the complete wild west when building and doing maintenance. It's not uncommon to end up with wildly different state management solutions in every project because the prevailing winds change so frequently. This can have a big effect on productivity and morale. It's one of the main reasons I'm trying to get out of programming for my profession. I'm so fucking tired of having to chase the flavor of the month.
Post reply on HN