Why states are still undefined after being passed to props via mapStateToProps?

24 Views Asked by At
const mapStateToProps = state => {
  console.log(state);
  return {
    counter: state.counter,
    isLogged: state.isLogged
  }
}

This is how I passed the states. However, error comes saying counter and isLogged is undefined. Why ?

1

There are 1 best solutions below

0
On

The state will contain an object with all your reducers so check if counter and isLogged are the names of your reducers. I would suggest removing the state.counter and the state.isLogged on the return and checking what the console.log(state) prints