Last active
May 5, 2020 16:39
-
-
Save showlovezz/3ab287d586758f6a8f5ed7a881b54a4f to your computer and use it in GitHub Desktop.
鼠年全馬鐵人挑戰 - React Hooks useState 2
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
import React, { useState } from 'react' | |
const Example = () => { | |
// useState 採用 callBack Function,必要 return 一個值 | |
const [count, setCount] = useState(() => { | |
return 0 | |
}) | |
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