#root
View Compiled
const { useState } = React;

function GreatCounter() {
  const [count, setCount] = useState(0);
  return (
    <div>
      <p>Current counter value:</p>
      <h2>{count}</h2>
      <button onClick={() => setCount(count + 1)}>
       Plus 1
     </button>
      <button onClick={() => {}}>
       Minus 1
     </button>
      <p>Last button clicked:</p>
      <h2>????</h2>
   </div>
  );
}

ReactDOM.render(<GreatCounter/>, document.getElementById("root"));
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js
  3. https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.8.7/polyfill.min.js