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 www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #useReducer
ADD COMMENT
Topic
Name
5+2 =