Reputation: 961
In my project i normally get data from reducers and pass data to component, in that component if data is to be updated e.g
obj :{ age:20, name: 'hassan' }
for any update action than i create copy of this object to my own state in constructor as
this.state {
obj : this.props.obj
}
then utilize copied obj and send to service for update actions to server side etc.
but i never update reducers object instead always create component own state.
I am new to react please guide me should i update reducers object and further utilize it instead to create own state for component and if i should update reducers object it effects permormance or currently pattern i am following is better or not ?
Upvotes: 0
Views: 24
Reputation: 81
The concept of redux comes down to maintaining a global state that can be accessed by any component.
The usage of the store differs based on the variable you are storing. It is recommended to store only the values which are being used by other components .If that's not the case you can maintain the state in indvidual react components.
redux store vs react state this tutorial gives a handfull experience to choose wisely
Upvotes: 1