reactjs - Receiving ALL props in a child component -
is possible receive props passed in child component without explicitly specifying them 1 one? eg:
const parentcomponent = () => { return <childcomponent prop1={"foo"} prop2={"bar"} prop3={"baz"} /> } const childcomponent = (props) => { return <input /*gimme props here*/ /> }
use spread operator -
const childcomponent = (props) => { return <input {...props} /> }
this gets automatically interpreted -
const childcomponent = (props) => { return <input prop1={"foo"} prop2={"bar"} prop3={"baz"} /> }
Comments
Post a Comment