import React, { useState } from "react"; import "./App.css"; const App = () => { const [counterA, setCounterA] = useState(0); const [counterB, setCounterB] = useState(0); return ( <div> <button onClick={() => { setCounterA(counterA + 1); }} > Increment A </button> <button onClick={() => { setCounterB(counterB + 1); }} > Increment B </button> <div>counterA: {counterA}</div> <div>counterB: {counterB}</div> </div> ); }; export default App;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter