Created
January 17, 2020 13:51
-
-
Save adedayojs/07725fa05cae44b9510234832c8b99f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counterReducer = (state, action) => { | |
switch (action.type) { | |
case 'INCREASE': | |
return { ...state, count: state.count + 1 }; | |
case 'DECREASE': | |
return { ...state, count: state.count - 1 }; | |
default: | |
return state; | |
} | |
}; | |
/* | |
This kind of reducer above doesn't make use of any payload | |
in the action so supplying a payload in the action is not needed. | |
That is why i said payload is optional. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment