First, in Reducer, the returned state must be a completely new object , otherwise redux will not execute the listening method, because Redux will assume that state has not been updated and there is no need to re-render the view.
Examples of problems that occur:
Const user= (state={name= ", age=0},action) = {switch( action.type) { case ' Change_name ': state.name= ' Zhangsan '; modifies the name return state in the original object ; default : return State ; } }
Yes, this is the case, even if the name value of the old state is modified, but Redux does not think the state has changed, I did not see the source code (rookie, to study for a long time), but the guess is, redux to each state attaches a key value, so, is to decide whether to re-render the view by judging key.
Second, Redux Combinereducers method, False with Reducer1 (signUp) and Reducer2 (SignIn), two reducer have action type (' Change_username '), You will find that in one of the view changes username, and the other username will follow,
In other words, even in different reducer, it is best not to have the same action type, otherwise there will be dirty data generated.
Redux two deadly key points encountered during use