Live data from Hacker News

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

news.ycombinator.com

11–20 of 47 posts

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

#13
Full disclosure, I’m the author of Breezy, https://github.com/jho406/Breezy. An opinionated state shape and PJAX library for Redux.

I think “how you shape your state to make it easy to reduce and share between components” is an important topic that’s taken a backseat when discussing state management tooling.

Should I repeat my backend models? Should I use a redux ORM? How much should I denormalize or normalize?

I found it much easier to just denormalize everything and shape state for presentational purposes, e.g, I have a bunch of page nodes in my redux state each with a duplicated header. If I need to make an update to the header in response to, say, a change in user email, I change each duplicated header individually.

Sounds insane but it really works for me and let’s me keep more business logic in the backend where it belongs.

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

#15
Redux. I really like keeping my state flat as the app I mainly work on has a lot of pages which use the same data. Complex component props are derived in mapStateToProps. I find reselect complex and hard to use with typescript, so I simply use memoized functions with memoize-one.

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

#16
Back when Redux was fairly new, we used a "mixin" architecture with a single component refreshing the entire global state of the application. Unfortunately, this has been a horrible decision and we're currently moving towards a Redux based solution. Nonetheless, the rendering is still impressive.

https://cellcollective.org

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

#17
If you don't have to support IE11, there has been a very interesting trend of JS Proxy based state managers (immer, react-easy-state, overmind, etc.). It reduces the boilerplate compared to redux while giving basically the same architecture. I have been using my own implementation, because react-easy-state did not work well with styled components (https://github.com/UgnisSoftware/lape), while I was building https://github.com/UgnisSoftware/Ugnis if you want to see this approach in use.

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

#20
Using redux v4 with react-redux v5 for a large and complicated project. Was looking into react-redux v6 but it looks like there may be a significant performance hit (https://github.com/reduxjs/react-redux/issues/1164) so will hold off on it now.

react-apollo is very interesting to me, but my understanding is that we'd need a graphql compatible backend, which we don't have

Post reply on HN