Last active
February 6, 2019 13:11
-
-
Save gisderdube/3ddd105ffd523980cd5514d9918de3d2 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
| // BAD EXAMPLE | |
| import React, { useEffect, useState } from 'react' | |
| function Counter() { | |
| const [count, setCount] = useState(0) | |
| useEffect(() => { | |
| const interval = setInterval(() => { | |
| setCount(count + 1) | |
| }, 1000) | |
| return () => { | |
| clearInterval(interval) | |
| } | |
| }, [count]) | |
| return ( | |
| <div> | |
| Current count is: {count} | |
| </div> | |
| ) | |
| } | |
| export default Counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment