Guest User

Untitled

a guest
Oct 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const INCREMENT = 'INCREMENT'; // define a constant for increment action types
  2. const DECREMENT = 'DECREMENT'; // define a constant for decrement action types
  3.  
  4. const counterReducer = (state = 0, action) => {
  5. switch(action.type) {
  6. case INCREMENT:
  7. return state + 1
  8. case DECREMENT:
  9. return state - 1
  10. default:
  11. return state;
  12. }
  13. }; // define the stateer reducer which will increment or decrement the state based on the action it receives
  14.  
  15. const incAction = state => {
  16. return {
  17. type: INCREMENT
  18. }
  19. } // define an action creator for incrementing
  20.  
  21. const decAction = state => {
  22. return {
  23. type: DECREMENT
  24. }
  25. }; // define an action creator for decrementing
  26.  
  27. const store = Redux.createStore(counterReducer); // define the Redux store here, passing in your reducers
Add Comment
Please, Sign In to add comment