()
| 1 | import { useEffect, useState } from 'react'; |
| 2 | |
| 3 | function App() { |
| 4 | |
| 5 | const [count,setCount] = useState(0); |
| 6 | |
| 7 | useEffect(() => { |
| 8 | console.log(count); |
| 9 | |
| 10 | setInterval(() => { |
| 11 | setCount(count => count + 1); |
| 12 | }, 1000); |
| 13 | }, []); |
| 14 | |
| 15 | return <div>{count}</div> |
| 16 | } |
| 17 | |
| 18 | export default App; |