<div id="root"></div>
import React from 'https://cdn.skypack.dev/react';
import ReactDOM from 'https://cdn.skypack.dev/react-dom';
const {useState} = React;
function Parent (){
const [state,setState] = useState(0);
return <div>
<p>count: {state}</p>
<button onClick={()=>{setState(c=>c+1)}}>Increment</button>
<Child state={state}/>
</div>
}
function Child({state}){
state = state+5;
return <div><p>count + 5 = {state} </p></div>
}
ReactDOM.render(<Parent/>,document.getElementById("root"))
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.