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…
Recoil – A state management library for React
21–30 of 83 posts
Re: Recoil – A state management library for React
#22What 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…
Re: Recoil – A state management library for React
#23What 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…
I'm not sure it's a hassle, just different schools of thought.
> This is not the case in other frameworks.
None of the examples you mention are reactive AFAIK. The point of React is that the UI is a function of the state. How exactly that is accomplished is where those different schools of thought come into the picture.
Re: Recoil – A state management library for React
#24I'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…
> I still haven't found anything that beats Redux on its own without thunks or sagas There was a period in the early days of Redux where MobX [0] (and, perhaps to a lesser extend, MobX State Tree [1]) was the main competitor to Redux that I used to hear about. They both seem to be actively developed, but I don't hear so much about them any more. Have you ever look at either of them? BTW I am 100% with you on Sagas. […
Only problem so far, or inconvenience maybe, is the sometimes complicated ways you come to intertwine stores which have access to different parts of the fetched API data. So if you need data Y stored in store X inside store Z, you have to inject store X as dependency to store Z. Getting too carried way with these injections can make your whole state quite messy. Or loading too much logic into one store.
Probably that's just an architectural issue, that can be remedied with enough thought put into it, but I haven't at least found a clear pattern that would make it simple to decide when to break up stores, or how to refactor them.
Also you have be aware of the complexities of observables which are a bit magical. Knowing when observables don't update and how to observe in general is very much a necessity (unless you want interesting bugs).
I have been curious to try out Mobx State Tree but alas haven't had time.
Re: Recoil – A state management library for React
#25I'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…
Why is everyone so eager to add third party state libraries from the getgo? In most projects, Redux doesn't add net value.
Re: Recoil – A state management library for React
#26What 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…
> What is it about React that state management is such a such a hassle? I'm not sure it's a hassle, just different schools of thought. > This is not the case in other frameworks. None of the examples you mention are reactive AFAIK. The point of React is that the UI is a function of the state. How exactly that is accomplished is where those different schools of thought come into the picture.
Here's one such lib: https://www.npmjs.com/package/mvc-router-spa
Re: Recoil – A state management library for React
#27What 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…
The main "Apple approved" tools for user interface and state management are CoreData and UIKit. Both are imperative, mutable, and overall difficult to work with. This might be subjective, but I always notice just how poorly Apple's own apps work. There is always some button that is stuck in the wrong state, some feature that doesn't do what its supposed to, and some broken animation when views reload (I'm looking at you Podcast app). I can't know why, but my hunch is that Apple engineers are forced to use unwieldy patterns and technologies like CoreData, MVC, and UIKit, and are drowning in a sea of unmaintainable code.
As a response to the inadequate tools Apple provides, big industry leaders have stepped up and rolled their own declarative solutions. IGListKit from Instagram is a prime example of a declarative user interface solution thats vastly superior to Apple's. Going even further, Facebook basically ported React into iOS with ComponentKit.
It took Apple a good decade, but they are finally giving us these types of tools as well with SwiftUI. However, judging from its low adoption, so far they have not managed to fully get things right.
Re: Recoil – A state management library for React
#28Earlier quoted context omitted.
MobX State Tree advocate here. We have a VERY complex state that needs to be synced with the server and persisted locally and nothing fulfilled our needs like MST. Also, sign me up to the Sagas-are-bullshit club.
Mobx itself is insufficient? What does mobx-state-tree provide that mobx does not? The README doesn't convey anything meaningful.
Re: Recoil – A state management library for React
#29What 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…
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…
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 view yourself.