<div id="root"></div>
body {
  padding: 5px;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}
button {
  border-radius: 4px;
	height: 40px;
	color: #fff;
	background: #c4c4c4;
	border: 1px solid inherit;
}
button:hover {
  color: #fff;
  background: #DD4B39;
}
.count {
  padding: 5px;
  margin: 5px;
  font-size: 2em
}
const { useState, useContext } = React

const CountContext = React.createContext();

const Counter = () => {
  const { count, increase, decrease } = useContext(CountContext);
  return (
    <div className="wrapper">
      <button onClick={decrease}>-</button>
      <span className="count">{count}</span>
      <button onClick={increase}>+</button>
    </div>
  );
};

const App = () => {
  const [count, setCount] = useState(0);

  const increase = () => {
    setCount(count + 1);
  };
  const decrease = () => {
    setCount(count - 1);
  };

  return (
    <div>
      <CountContext.Provider
        value={{ count, increase, decrease }}
      >
        <Counter />
      </CountContext.Provider>
    </div>
  );
};

ReactDOM.render(<App />, document.getElementById("root"))
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.com/react@16.7.0-alpha.0/umd/react.production.min.js
  2. https://unpkg.com/react-dom@16.7.0-alpha.0/umd/react-dom.production.min.js
  3. https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js