javascript - Best way to pass props for react component -
in react js can pass component props in 2 ways:
<component prop1={value} prop2="value" prop3={this.othervalue} />
or
let props = { prop1: value, prop2: "value", prop3: this.othervalue } <component {...props} />
what variant better?
which prefer? neither "right", though think you're more see first variant, since seems bit clearer pass props explicitly. spread params variant used avoid duplication - if specify props on parent want pass them child, spelling them out explicitly on child feels bit laborious.