Created
July 9, 2019 20:22
-
-
Save vitalybe/bb2b05d90793f18840c133d5ee8defd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App({ date }) { | |
const [currentDate, setCurrentDate] = useState(new Date()); | |
const [count, setCount] = useState(0); | |
const prettyDate = useMemo(() => formatDate(currentDate), [currentDate]); | |
return ( | |
<div className="App"> | |
<h1>Hello CodeSandbox</h1> | |
<h2> | |
You clicked {count} times, last time at {prettyDate}! | |
</h2> | |
<button onClick={() => updateCount(-1, setCount, setCurrentDate)}>Decrement</button> | |
<button onClick={() => updateCount(1, setCount, setCurrentDate)}>Increment</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment