<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({count:0});
return <div>
<p>count: {state.count}</p>
<button onClick={()=>{setState(c=>{return {count:c.count+1}})}}>Increment</button>
<Child state={state}/>
</div>
}
function Child({state}){
state.count= state.count+5;
return <div><p>count + 5 = {state.count} </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.