How to use map the correct way?

Tell us what’s happening:
As you can see, my code is wrong.
Your code so far


const state = [];

// Change code below this line
function mapStateToProps() {
return state.map((st = messages) => <li key={st}> st</li>);
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36.

Challenge: Map State to Props

Link to the challenge:

Hi @amejl172,
The instructions say:
This function should take state as an argument, then return an object which maps that state to specific property names.

In your code:
function mapStateToProps() {
}

You need to pass the state as an argument to the function:
function mapStateToProps(state) {
}
.

The next part of the function needs to return an object and have a property called messages passing state as the value
e.g.
return {
messages: state
}

Let me know if you need any help :slight_smile:

1 Like

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