Live data from Hacker News

Recoil – A state management library for React

recoiljs.org

41–50 of 83 posts

Re: Recoil – A state management library for React

#42

Earlier quoted context omitted.

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

> You don't need any of that if you just use React.

You do need it if you use ReactRouter. Otherwise your state will be spread (or duplicated even) across multiple components, and it will be a nightmare to deal with.

Re: Recoil – A state management library for React

#47
post #46

Seems to be roughly the same amount of boilerplate as useContext, so I don't fully understand the separate purpose for it?

Recoil allows you to create atoms and selectors in loops without having to add an entire new Context.Provider component to the root of the React component tree, which would obviously not be viable since the entire tree would need to be torn down each time.

Re: Recoil – A state management library for React

#48

Earlier quoted context omitted.

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

> You don't need any of that if you just use React. You do need it if you use ReactRouter. Otherwise your state will be spread (or duplicated even) across multiple components, and it will be a nightmare to deal with.

Whats stopping you from just importing a plain javascript module that has mutable data on all your screens? You can even write it to local storage on every update to preserve it across app refreshes.

Thats essentially what you have in iOS with your AppState example. There is no need to use a Reactive Store if you just want to share some state between screens.

Re: Recoil – A state management library for React

#49
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…

Agreed. But Redux loop is nice. Kinda like reframe for JavaScript.

Re: Recoil – A state management library for React

#50
post #36

Seems like compared to Redux this would make server-side rendering very challenging. Each atom is a global singleton so I'm not sure how you could render individual requests.

It’s actually designed to make server rendering easy. We’ll add a guide about this eventually. Atoms aren't global singletons: their values are scoped to React trees.
Post reply on HN