Skip to content

Instantly share code, notes, and snippets.

@vitalybe
Created July 9, 2019 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitalybe/bb2b05d90793f18840c133d5ee8defd3 to your computer and use it in GitHub Desktop.
Save vitalybe/bb2b05d90793f18840c133d5ee8defd3 to your computer and use it in GitHub Desktop.
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