pass props to a component that was rendered as prop code example
Example 1: pass props in react
const expression = 'Happy';
<Greeting statement='Hello' expression={expression}/>
class Greeting extends Component {
render() {
return <h1>{this.props.statement} I am feeling {this.props.expression} today!</h1>;
}
}
Example 2: pass component as props react
const Label = props => <span>{props.children}</span>
const Button = props => {
const Inner = props.inner;
return <button><Inner>Foo</Inner></button>
}
const Page = () => <Button inner={Label}/>