callBack function in Redux

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

// 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 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0

Challenge: Register a Store Listener

Link to the challenge:

please explain in little more detailed way.

Yes, please ask a question.

Looking at your code:

// Global count variable:
let count = 0;

// Change code below this line

// Change code above this line

There should be something in between those comments. You’re supposed to implement this instruction:

Write a callback function that increments the global variable count every time the store receives an action, and pass this function in to the store.subscribe() method.

Is there a part of that you don’t understand? Please be specific.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.