Map State to Props (using arrow function)

Tell us what’s happening:
Tried writing this in arrow function, but it doesn’t work. Not sure why…

Your code so far


const state = [];

// change code below this line
/*function mapStateToProps(state) {
  return {
    messages: state
  }
}
*/
var mapStateToProps = (state) => {messages: state};

Your browser information:

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

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

you forgot the brackets

var mapStateToProps = (state) => ({messages: state});

(the brackets are necessary when you are writing short-hand functions)

1 Like

Thanks @hbar1st & @camperextraordinaire!

I have a better understanding now