Tell us what’s happening:
Describe your issue in detail here.
Your code so far
const ADD = 'ADD';
const reducer = (state = 0, action) => {
switch(action.type) {
case ADD:
return state + 1;
default:
return state;
}
};
const store = Redux.createStore(reducer);
// Global count variable:
let count = 0;
// Change code below this line
const addOne = () => (count += 1);
function sayHi() {
console.log("Hi");
}
store.subscribe(sayHi)
// Change code above this line
store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});
console.log(count);
store.dispatch({type: ADD});
console.log(count);
Your browser information:
User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1
Challenge: Redux - Register a Store Listener
Link to the challenge:
https://www.freecodecamp.org/learn/front-end-development-libraries/redux/register-a-store-listener don’t know what’s wrong with my code