Redux: combineReducers does not remove unexpected keys when reducers have no changes

Created on 19 May 2016  路  2Comments  路  Source: reduxjs/redux

For example in the following, I would expect newState to equal { id: 1234, name: 'hello' } but it instead returns currentState.

const currentState = { id: 1234, name: 'hello', unexpected: 4567 };
const reducer = combineReducers( { id, name } );
const newState = reducer( currentState, {} );

The additional key is harmless in code, but it is annoying since an error warning may be printed to console repeatedly. This case is pretty easy to run into if the redux tree is persisted and the data shape changes.

bug

Most helpful comment

For now, let鈥檚 do something different. I propose we keep a cache for properties we warned about in development, and don鈥檛 warn about them the second time.

All 2 comments

Good point. This should be easy to fix. Would you like to take a stab at it?

For now, let鈥檚 do something different. I propose we keep a cache for properties we warned about in development, and don鈥檛 warn about them the second time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmitry-zaets picture dmitry-zaets  路  3Comments

benoneal picture benoneal  路  3Comments

ramakay picture ramakay  路  3Comments

olalonde picture olalonde  路  3Comments

mickeyreiss-visor picture mickeyreiss-visor  路  3Comments