Events
Handle user actions with onClick and onChange
Key points
- Handle clicks with onClick and typing with onChange. Unlike HTML's onclick, the second word is capitalized
- Pass "a function to run later". Write onClick={handleClick} without ()
- To call it with arguments, wrap it in () =>: onClick={() => setCount(0)}
Try it
- Add an "Undo" button that resets the message to the original
- Change onClick to onMouseEnter so it reacts when you just hover over it
- Try adding () like onClick={handleClick()} and see what happens