I am trying to learn ReactJS and I'm having some trouble understanding the destructuring occurring in the following snippet:
const IngredientsList = ({ list }) =>
React.createElement('ul', null,
list.map((ingredient, i) =>
React.createElement('li', {key: i}, ingredient))
const Ingredients = React.createFactory(IngredientsList)
const list = [
"1 lb Salmon",
"1 cup Pine Nuts",
"2 cups Butter Lettuce",
]
This should be equivalent to:
const IngredientsList = props =>
....
props.list.map(...)
I thought only on an object such a destructuring is available. Can you shed some light how the two of above are equivalent? Is it something specific to react?
propsis an object.listis an array passed down to the component inprops.