What's the meaning of "state = 5" in the reducer?

Could you tell me what the meaning of “(state =5)” is in the reducer? It means if the next state is equal to 5, then react the state equal to 5?

  **Your code so far**

const reducer = (state = 5) => {
return state;
}

// Redux methods are available from a Redux object
// For example: Redux.createStore()
// Define the store here:
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36

Challenge: Create a Redux Store

Link to the challenge:

If there was no argument passed to the function, the default input is 5.

1 Like
1 Like

Yes, remember that when the reducer is first called, when redux is setting up, the state is unefined. You have to give it an initial value.

1 Like

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