V
V
Vanya Huk2018-07-27 23:03:31
redux
Vanya Huk, 2018-07-27 23:03:31

How to get the initial state of the reducer?

How to get the initial state of the reducer?
Here is an example code, but for some reason it doesn't work

const initialState = {

  message  : false,

  key: null

}


const notification = (state = initialState , action) => {

  switch( action.type ){

    case "UPDATE_NOTIFICATION":
      return Object.assign({}, state, action.payload );

    case "RESET_NOTIFICATION":
      return initialState;

    default :  return state;

  }
}

export default notification;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question