TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Recoil – A state management library for React

109 pointsby dar8919about 5 years ago

18 comments

mariusandraabout 5 years ago
I&#x27;m someone who through sheer coincidence (the right projects at the right time) happened&#x2F;lucked into developing a React state management solution (<a href="https:&#x2F;&#x2F;kea.js.org" rel="nofollow">https:&#x2F;&#x2F;kea.js.org</a>). I&#x27;ve probably sunk hundreds of hours into this project by now.<p>5 hours before this HN post I asked for comparisons with different site management libraries on Github here: <a href="https:&#x2F;&#x2F;github.com&#x2F;keajs&#x2F;kea&#x2F;issues&#x2F;106" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;keajs&#x2F;kea&#x2F;issues&#x2F;106</a><p>React state management is indeed a mess, meaning there are so many options to choose from. Unfortunately, even for me, a library author, it&#x27;s hard to evaluate all of them properly. It would take just too much time and you never know where the real problems in any framework lay before you get neck-deep in code. And then you&#x27;re too far to switch to another framework anyway.<p>Someone should really map out this landscape in more depth than just an awesome list. I hope the issue linked above can spark some discussion.<p>In any case, I personally think Kea is a very good solution for React state management, yet obviously I&#x27;m biased. Shrug.<p>And, to keep it on the topic, Recoil seems very low level and I think you need to invent a lot of things yourself to get a full app out of it. Cool to see people trying stuff though :).<p>And it&#x27;s from Facebook so who knows, just by proxy it might become the default &quot;atom&quot; and someone will build molecules out of them...
评论 #23200605 未加载
评论 #23190539 未加载
weeksieabout 5 years ago
I&#x27;m not seeing how this works with more complex state flows. Doesn&#x27;t seem much better than useReducer.<p>Frankly, for state management I still haven&#x27;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&#x27;s not.<p>Thunks are unmaintainable. Sagas are put together with bailing twine and rely too much on generators for my taste. (The source code is smart but it&#x27;s also wildly complex.) All of it is castles in the sky for no good reason. You don&#x27;t need any of that anyway.
评论 #23183177 未加载
评论 #23183326 未加载
评论 #23183964 未加载
评论 #23184210 未加载
评论 #23185735 未加载
评论 #23185383 未加载
评论 #23190277 未加载
saranshkabout 5 years ago
Here&#x27;s an awesome video from the library author explaining a bit more about Recoil from today&#x27;s React Europe live stream if anyone is interested: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=_ISAA_Jt9kI" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=_ISAA_Jt9kI</a>.
josemaenzoabout 5 years ago
I&#x27;m happy that we are moving away from the redux-like standard. I&#x27;ve tried the API in a dumb example and it looks clean and easy. <a href="https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;three-buttons-example-with-recoil-qiqhf" rel="nofollow">https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;three-buttons-example-with-recoil-q...</a><p>Still don&#x27;t like the extra naming that you have to think of for every atom&#x2F;value. Or also the key: prop that you have to define for every atom. It seems redundant for me.<p>And also, as a bundle-phobia guy I am. I think 22kb as extra library is ok but it could be better.<p>Liking a lot Recoil as solution for the three-button problem. I still think that the patch pattern I use with dop is better. In terms of simplicity and extra KB. This is the same example <a href="https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;react-dop-nhj0j?file=&#x2F;store.js" rel="nofollow">https:&#x2F;&#x2F;codesandbox.io&#x2F;s&#x2F;react-dop-nhj0j?file=&#x2F;store.js</a><p>But I guess I say that because I&#x27;m the creator of dop. So I&#x27;m so open to critics :)
flowerladabout 5 years ago
What is it about React that state management is such a such a hassle? This is not the case in other frameworks.<p>Consider iOS for example. Just add fields in App and you&#x27;re done: <a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;swift&#x2F;maintaining_state_in_your_apps" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;swift&#x2F;maintaining_...</a><p>Similarly in ASP.NET: <a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;previous-versions&#x2F;aspnet&#x2F;75x4ha6s(v%3Dvs.100)" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;previous-versions&#x2F;aspnet&#x2F;75...</a><p>Same in JSP: <a href="https:&#x2F;&#x2F;javabeginnerstutorial.com&#x2F;jsp-tutorial&#x2F;state-management-in-jsp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;javabeginnerstutorial.com&#x2F;jsp-tutorial&#x2F;state-managem...</a><p>But in React it is such a huge issue, and there are multiple competing solutions. There must be something wrong with the design of React that is causing this.
评论 #23184250 未加载
评论 #23184027 未加载
评论 #23183891 未加载
评论 #23183900 未加载
评论 #23184314 未加载
评论 #23183895 未加载
cwackerfussabout 5 years ago
Check out easy-peasy. Ive used plain ol redux, mobx, and xstate, but easy-peasy is the fricken best. It&#x27;s basically a redux wrapper that combines redux, thunks, reselect, redux logger, immer, and more into a super intuitive interface. The typescript support is super good and interacting with the API feels very modern and hook-driven.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ctrlplusb&#x2F;easy-peasy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ctrlplusb&#x2F;easy-peasy</a>
评论 #23187884 未加载
knubieabout 5 years ago
Sounds a lot like re-frame[1] (which I believe predates Redux), they even call the state &quot;atoms.&quot;<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;Day8&#x2F;re-frame" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Day8&#x2F;re-frame</a>
评论 #23183558 未加载
jwileyabout 5 years ago
It would be useful to have a more direct comparison between this and Redux (assuming its not on the website and I missed it). In what use-cases is it preferable, in which would it not be a good fit? In the comments you mention O(1) vs O(n), diving more deeply into that would be helpful as well.
评论 #23183757 未加载
bfrydlabout 5 years ago
Seems like compared to Redux this would make server-side rendering very challenging. Each atom is a global singleton so I&#x27;m not sure how you could render individual requests.
评论 #23185451 未加载
sheerunabout 5 years ago
In a year people will rediscover MobX I guess...
评论 #23184483 未加载
mmerickelabout 5 years ago
Is there any support for changing multiple atoms at once &#x2F; batch? This is where reducers shine to me - dispatching a single action from the ui in redux that multiple reducers can listen to and use to update their state.<p>Also is there any support for getting the values of atoms outside of a hook? For example from an async action that is not coupled to the render loop which also wants to know the current value.
评论 #23183427 未加载
rhackerabout 5 years ago
Seems to be roughly the same amount of boilerplate as useContext, so I don&#x27;t fully understand the separate purpose for it?
评论 #23185279 未加载
bodhibyteabout 5 years ago
Can anyone shed some light on if and how this might be used together with xstate (<a href="https:&#x2F;&#x2F;xstate.js.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xstate.js.org&#x2F;</a>) which is based on the SCXML spec?
评论 #23192920 未加载
ecnrvsrpabout 5 years ago
Anyone else see Svelte stores when they look at this?
sawyerjhoodabout 5 years ago
Great work on this davidmccabe! I remember hearing about this just before I left FB and am so glad that it is open source now.
rsifyabout 5 years ago
I wish he would have shown the heavy tree example in 11:55 without the library, seems cute and all but if you don&#x27;t provide a comparison it&#x27;s hard to take seriously.
saranshkabout 5 years ago
Conceptually, this looks very similar to observables and RxJs. Should be interesting to explore further.
pppmabout 5 years ago
Ffff