Live data from Hacker News

Ask HN: How do you manage state in your React application?

news.ycombinator.com

41–47 of 47 posts

Re: Ask HN: How do you manage state in your React application?

#42
New businesses intending to incorporate mobile apps wish to get the best developers. These fledgling businesses and the developers find React Native apps as the best choice. Until the publishing of this article, React Native apps market accounts for 12.56% of the most downloaded mobile apps. The developers at MobInspire use multiple frameworks and keep testing the emerging ones. However, the leadership stays affirmed that React is the prime choice.

Re: Ask HN: How do you manage state in your React application?

#44
post #6

Pass the things returned from useReducer() hook (state object + dispatch function) down via context. Then useContext() in child components.

How can you implement that, the useReducer must be inside the hooks component, so how can I export the value returned from useReducer to pass it into createContext ?

Re: Ask HN: How do you manage state in your React application?

#46
post #4

We use Redux at work for larger projects, React setState/Context for smaller ones, and I'm personally a huge fan of mobx-state-tree which I think is the best solution, and can be plugged into Redux if needed. I think Redux should not be used for everything (there are libraries like Redux-Form which I think are an anti-pattern as ephemeral state like that should never go through the root reducer on every key change)

I hate redux-form so. much.

Haters will hate! :)

Re: Ask HN: How do you manage state in your React application?

#47

Been using MobX for about three years and I think it is wonderful. Incredibly easy to use (mark your variable as observable, modify it like you would any normal variable, and any components which use those variables in their rendering and are marked as observers automatically update), very performant out of the box (only components affected by a change re-render so no shouldComponentUpdate needed) and some excellent…

There is a new alternative to MobX/MST - Reactronic:

https://github.com/Nezaboodka/reactronic#readme

It is transactionally reactive state management library for JavaScript. Key difference from MobX/MST is that Reactronic doesn't enforce developers to stick with MST rules of building the structure of state - the state can be a set (graph) of usual JS objects.

Also, Reactronic has minimal set of concepts, just three: State, Transaction, and Cache. So, it is easier to use.

Drawback is that it's a new thing and is not yet battle tested.

Post reply on HN