-1

What is the difference between using {} and not when passing in properties?

Ie

TodoApp = ({props}) => {
    console.log(props)
} 

and

TodoAp = (props) => {
    console.log(props)
}
Morgan Allen
  • 3,291
  • 8
  • 62
  • 86
  • https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment – kind user Jul 04 '17 at 13:36
  • Possible duplicate of [What is the name of the ... operator?](https://stackoverflow.com/questions/44786495/what-is-the-name-of-the-operator) – Hitmands Jul 04 '17 at 13:52

1 Answers1

2

This is ES6 syntax and not react.

as written in MDN:

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

To the specific example, In the first example you will unpack the object and take the "props" property out of it, where in the second example you will get the whole object and in order to get the property called "props" you will have to write props.props

Community
  • 1
  • 1
Matan Bobi
  • 2,693
  • 1
  • 15
  • 27