"Connect Redux to React"

"Connect Redux to React"
0

#1

Tell us what’s happening:
What code can I do to connect Redux to React?
I belive this is easy but what can I do to pass the test?

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

Your browser information:

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

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


#2

Pass in the functions as arguments, and immediately call the result with your component.


#3

And how can I do this?


#4

Their are two functions which can pass in the connect

mapStateToProps() and the mapDispatchToProps() functions,

see the syntax as below and try to code it again:

connect(mapStateToProps, mapDispatchToProps)(MyComponent)