What does {...this.props}
mean in this code?
<div {...this.props} style={{ height: `100%`, }}
What does {...this.props}
mean in this code?
<div {...this.props} style={{ height: `100%`, }}
The {...variable}
syntax is called "spread attributes".
What this does is, basically, it takes every property of this.props
(or any other passed variable) and applies them to the element.
Example:
props = {className: 'big', href: 'http://example.com'};
<a {...props} />
// the above line is equal to the following
<a className="big" href="http://example.com" />
I think it might be the spread operator (three dots) that are setting you off? :)
What does the three dots in react do?
Edit: To elaborate, you're probably looking at a JSX template? Each property will in fact be a CSS property for your style attribute in the resulting HTML. Also, the spread operator makes it so that all properties within this.props get expanded, i.e. the same thing as if each property in this.props was explicitly output in the template.
{...this.props} means all of the props of current component. Let say you have object a and object b in props than {...this.props} means both a and b. You can pass all of your current component's props to another component by using this.