Passing A Function

Similarly, with useContext() you can easily pass a callback such as a state update function deep down the component tree.
RESETRUNFULL
const MyContext = React.createContext(null);function Example() {
   const [count, setCount] = React.useState(0);
   return (<MyContext.Provider value={setCount}>
                 <div><p>Counter: {count}</p>
                          <A/>
                 </div>
              </MyContext.Provider>);}function A(){ return <B/>;}function B(){ return <C/>;}function C(){ return <D/>;}function D(){ return <E/>;}function E(){
   const sc = React.useContext(MyContext);   // accessible by any inner function too
   return <button onClick={()=>sc(n=>(n+1))}>+1</button>;}ReactDOM.render(<Example/>,document.querySelector("div"));