cannc4 / Siren

Algorithmic Composition Interface
https://ince.io/Siren_NIME18.pdf
GNU General Public License v3.0
156 stars 9 forks source link

Do not use passed parameter 'state' directly. #33

Closed doguhanokumus closed 6 years ago

doguhanokumus commented 6 years ago

https://github.com/cannc4/Siren/blob/7fcf5a4a285dc246b9f8c50c4a853d58d0273308/src/reducers/user.js#L6

You should use

let updatedState = Object.assign({}, state, {
   key: value
});
return updatedState;

to update the state from a reducer.

The reason for this is that the referred object might be removed/changed while you are in the reducer and this might cause bugs.

cannc4 commented 6 years ago

Thanks for the tip. We're currently refactoring the code, will keep that in mind