InterviewSolution
| 1. |
Explain Reducers In Redux? |
|
Answer» The STATE of a store is updated by means of reducer functions. A stable collection of a reducers form a store and each of the stores maintains a separate state associated for itself. To update the ARRAY of donors, we should define donor application Reducer as follows. export default function donorReducer(state = [], action) { SWITCH (action.type) { case actionTypes.addDonor: return […state, action.donor]; default: return state; } } The initial state and action are received by the reducers. Based on the action type, it returns a NEW state for the store. The state maintained by reducers are immutable. The below-given reducer it holds the current state and action as an argument for it and then returns the next state:function handelingAuthentication(st, ACTN) { return _.assign({}, st, { auth: actn.pyload }); } The state of a store is updated by means of reducer functions. A stable collection of a reducers form a store and each of the stores maintains a separate state associated for itself. To update the array of donors, we should define donor application Reducer as follows. export default function donorReducer(state = [], action) { switch (action.type) { case actionTypes.addDonor: return […state, action.donor]; default: return state; } } The initial state and action are received by the reducers. Based on the action type, it returns a new state for the store. The state maintained by reducers are immutable. The below-given reducer it holds the current state and action as an argument for it and then returns the next state:function handelingAuthentication(st, actn) { return _.assign({}, st, { auth: actn.pyload }); } |
|