1//Render props are functions that are passed to props as values
2const User = (props) => {
3 const [name, setName] = useState('John')
4
5 //we pass values to prop-function as args
6 return <div>{props.render(name)}</div>
7}
8
9//Then we can use this component like this:
10<div>
11 //when using the component we receive the passed values (name) as args here
12 <User render={(name) => <div>{name}</div>} />
13</div>
14
15
1function Welcome(props) { return <h1>Hello, {props.name}</h1>;
2}
3
4const element = <Welcome name="Sara" />;ReactDOM.render(
5 element,
6 document.getElementById('root')
7);