score:1

Accepted answer
const Shower = () => {
  const { count } = useCounter();    
  return count;
}

const Setter = () => {
  const { count, setCount } = useCounter();    
  return <button onClick={() => setCount(count+1)}>
    Add
  </button>
}

const App = () => {
  return (
    <CounterProvider>
      <div className="App">
        <Setter />
        <Shower />
      </div>
    </CounterProvider>
  );
}

score:0

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.3/umd/react-dom.production.min.js"></script>

<div id="root"></div>

Related Query

More Query from same tag