Last active
April 14, 2019 20:40
-
-
Save YKalashnikov/b5ad6cce1e5ac18a68e94958719dc3cd to your computer and use it in GitHub Desktop.
This file contains 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 CounterHooks() { | |
const [count, setCount] = useState(0); | |
const [time, setTime] = useState(new Date()) | |
// 🐢 look here. | |
useEffect(() => { | |
console.log("useEffect first timer here.") | |
}, [count]) | |
const handleClick = () => { | |
setCount(count + 1); | |
setTime(new Date()) | |
} | |
return ( | |
<div> | |
<h3 className="center">Welcome to the Counter of Life </h3> | |
<button className="center-block" | |
onClick={handleClick}>{count}</button> | |
<p className="center"> at: {`${time.getHours()} : ${time.getMinutes()} : ${time.getSeconds()}`}</p> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment