Skip to content Skip to sidebar Skip to footer

Mapstatetoprops Is Not Running

I am new to react and I can't debug why mapStateToProps is not running. Pls see the last function in login.js. I have added alert statements in my mapStateToProps function but its

Solution 1:

I assume that it is mapDispatchToProps that isnt working, right? Try this

...    
constmapDispatchToProps = (dispatch) => (
    return { 
        sendTheAlert(coin) {
            debugger;
            alert();
            returndispatch(userConstants.LOGIN_REQUEST) }
    })

A sample of how to structure mapDispatchToProps would be (from https://react-redux.js.org/using-react-redux/connect-mapdispatch). Be mindful of the return statement.

const mapDispatchToProps = dispatch => {
  return {
    // dispatching plain actions
    increment: () => dispatch({ type: 'INCREMENT' }),
    decrement: () => dispatch({ type: 'DECREMENT' }),
    reset: () => dispatch({ type: 'RESET' })
  }
}

Solution 2:

Post a Comment for "Mapstatetoprops Is Not Running"