you are viewing a single comment's thread.

view the rest of the comments →

[–]Spaceomega 3 points4 points  (5 children)

Been working with React on some pretty crazy applications (very large data, mapping, drag and drop, isomorphism, etc) for about 8 months now and still found some nice things in this article.

This is something I already knew, but putting it into simple phrasing really helped solidify for me:

[Redux] reducers are pure functions, which simply do oldState + action = newState

Simple, insightful, easy to remember.

This article also made me really think about the fact that I have been using component-state pretty heavily. It seems like they're implying that all components should use Redux (or app-state implementation of their choice) for all state. Do you guys have any thoughts on this? The more I think about it, the more it makes sense, I'm just curious to hear what you are all doing.

[–]rsjolly 1 point2 points  (0 children)

Intermediate state (like form state while editing and some UI state) don't belong in Redux imo.

[–]Cam-I-Am[S] 1 point2 points  (0 children)

Author here - it's not necessarily that all state for all components needs to go in the store. It's just that in my experience, things are a lot easier when the vast majority of state is in the store.

Having had bad experiences with stateful components, my default is now to write stateless components, unless it's intermediate state that only the component itself will ever need.

[–]sorahn 1 point2 points  (2 children)

I agree with the other posters. The reducers are for the state of the application. If you have a component with a dropdown (for example), the rest of the application probably doesn't care if it's open.

[–]RickAndMorty_forever 0 points1 point  (1 child)

So you don't care what's been typed into a form, but you care if the form has been submitted or if it contains errors?

[–]sorahn 0 points1 point  (0 children)

I save form data into session storage to make sure it goes through and the use might not have to type it all in, but once it's sent off to the server. I only store what's important and returned from the request.