Skip to content

Instantly share code, notes, and snippets.

@showlovezz
Last active May 3, 2020 16:07
Show Gist options
  • Save showlovezz/d6ce214db67f8abbf77bae128516dcf4 to your computer and use it in GitHub Desktop.
Save showlovezz/d6ce214db67f8abbf77bae128516dcf4 to your computer and use it in GitHub Desktop.
鼠年全馬鐵人挑戰 - React Hooks useEffect 1
import React, { useState, useEffect } from 'react'
const Example = (props) => {
const [count, setCount] = useState(0);
useEffect(() => {
// 更新頁面標題
document.title = `You clicked ${count} times`
})
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