props
function Car(props) {
return <h2>I am a { props.brand }!</h2>;
}
function Garage() {
return (
<>
<h1>Who lives in my garage?</h1>
<Car brand="Ford" />
</>
);
}
ReactDOM.render(<Garage />, document.getElementById('root'));
Sources
- React Props
- Example is listed above
- React State Vs Props - YouTube
- Props are for initializing stuff from a parent element
- If the element does not update from within props are ideal
- Render Props – React
- Too complex
- Components and Props – React