Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useReducer

function reducer(state, action) {
  switch (action.type) {
    case 'incremented_age': {
      // ✅ Instead, return a new object
      return {
        ...state,
        age: state.age + 1
      };
    }
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #useReducer
ADD COMMENT
Topic
Name
2+9 =