Please help me with the Topic Register a Store Listener

Tell us what’s happening:

Your code so far


const ADD = 'ADD';

const reducer = (state = 0, action) => {
  switch(action.type) {
    case ADD:
      return state.count + 1;
    default:
      return state.count;
  }
};

const store = Redux.createStore(reducer);

// global count variable:
let count = 0;
// change code below this line
// change code above this line
store.subscribe( () => count +=1 )

store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.

Link to the challenge:

Hi, your learning the Redux then Please explain the code . I am also started the Redux but i didn’t idea about the React and Redux. if you don’t mind.

You don’t need state.count + 1, you only need state + 1. No need to access the undefined count property