JSFiddle - React, Tailwind, and code Playground

by eget teteete

JavaScript

let reducer = (state = 0, action) => {
  switch (action.type) {
    case 'INC':
      return state + 1;
    default:
      return state
  }
}

let state = reducer(3, {});
state = reducer(state, {
  type: 'INC'
});
console.log(state)