Created
May 5, 2020 16:36
-
-
Save showlovezz/7e178dfb16f29f09b8b48d16e00d09a0 to your computer and use it in GitHub Desktop.
鼠年全馬鐵人挑戰 - React Hooks useEffect 5
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
const App = () => { | |
const [count, setCount] = useState(0) | |
useEffect(() => { | |
// 副作用邏輯 | |
document.title = `You clicked ${count} times`; | |
}, [count]) | |
useEffect(() => { | |
console.log(count) | |
}) | |
return ( | |
<div> | |
<p>You clicked {count} times</p> | |
<button onClick={() => setCount(count + 1)}> | |
Click me | |
</button> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment