Trouble understanding JSX spread operator [duplicate]

This helps make your code more succinct – since props is an object, the spread operator takes the properties of the object you pass in and applied them to the component. So the Component will have properties a foo with a value of x and a bar with a value of y.

It would be the same as:

var component = <Component foo={props.foo} bar={props.bar} />;

just shorter

Leave a Comment