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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -