I currently have my store setup. Various things trigger events to update the store, which updates props downstream. This is really handy when triggering something to make updates in multiple components.
Is it anti-pattern to use state for things no other components care about?
I basically have a component that is a page of a form. Editing the form updates state (ie selecting one option makes other options change). I figure when the user hits save, I will trigger event for store to have the new data. Hitting cancel would just go back to another page so returning later will just repopulate from store state.
Does that make sense?
Using internal state is perfectly fine (and encouraged!) in simple behavior like what you describe. Things like the state of a modal (open/close), checkboxes, and other minor things like that are perfectly fine contained within React state.
Remember that Redux is most useful in handling global app state. When trying to decide where to keep state, try answering the question "Will any other part of the app care at all about a change to this?" If so, use the Redux store. Otherwise, go ahead with internal state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With