-
Notifications
You must be signed in to change notification settings - Fork 293
Reducers
Haz edited this page Apr 2, 2017
·
6 revisions
Reducers are pure functions which are called sequentially when some action is dispatch
ed. With them you can perform state changes based on the dispatched action.
A simple reducer will look like this:
const reducer = (state, action) => {
switch (action.type) {
case 'RESOURCE_CREATE':
return {
...state,
list: [ action.detail, ...state.list ],
}
default:
return state
}
}
Special thanks to @kybarg and @protoEvangelion for helping to write this Wiki. Please, feel free to edit/create pages if you think it might be useful (also, see #33)