Skip to content

Instantly share code, notes, and snippets.

@showlovezz
Created May 5, 2020 16:36
Show Gist options
  • Save showlovezz/7e178dfb16f29f09b8b48d16e00d09a0 to your computer and use it in GitHub Desktop.
Save showlovezz/7e178dfb16f29f09b8b48d16e00d09a0 to your computer and use it in GitHub Desktop.
鼠年全馬鐵人挑戰 - React Hooks useEffect 5
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