Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

context

export const actionType = {
  SET_USER: 'SET_USER',
}

const reducer = (state, action) => {
  console.log(action)

  switch (action.type) {
    case actionType.SET_USER:
      return {
        ...state,
        user: action.user,
      }
    default:
      return state
  }
}

export default reducer
 
PREVIOUS NEXT
Tagged: #context
ADD COMMENT
Topic
Name
6+9 =