In React, normally, we pass props to child component by following way:
const Parent = ({ foo, bar, baz, myFoo, myBar, myBaz }) => <Child foo={foo} bar={bar} baz={baz} /> (1)
Currently I figured out an alternative way to do this:
const Parent = ({ foo, bar, baz, myFoo, myBar, myBaz }) => <Child {...{ foo, bar, baz }} /> (2)
IMO, (2) saves a lot of time and typing effort. However:
- Are there any cons with (2)? For example, is (2) considered as React anti-pattern?
- I know talking about performance without measuring is bad, but I wonder if there are any hurt performance issues with (2)?
Update 1: I have added myFoo, myBar, myBaz
in Parent's props. Please note that I do not want to spread all props to Child component, because it's considered as bad practice that results in unnecessary props in Child component.