Connect Redux to React

Tell us what’s happening:

The test “The Presentational component should receive a prop messages via connect.” is not passing, and I can’t see whats wrong in my code.

Your code so far


const addMessage = (message) => {
  return {
    type: 'ADD',
    message: message
  }
};

const mapStateToProps = (state) => {
  return {
    messages: state
  }
};

const mapDispatchToProps = (dispatch) => {
  return {
    submitNewMessage: (message) => {
      dispatch(addMessage(message));
    }
  }
};

class Presentational extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return <h3>This is a Presentational Component</h3>
  }
};

const connect = ReactRedux.connect;
// change code below this line
const ConnectedComponent = connect(mapDispatchToProps, mapStateToProps)(Presentational)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react-and-redux/connect-redux-to-react/

Hi @MarcosRZ

You’ve passed in mapStateToProps and mapDispatchToProps in the wrong order to the connect function.

1 Like

:man_facepalming:

Thank you, guy. I’m f* blind…

2 Likes