Last active
March 23, 2021 03:18
-
-
Save night-fury-rider/048e6e831d9fb3e670119d65c9e127f4 to your computer and use it in GitHub Desktop.
React Hook - useState
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'; | |
function Example() { | |
const [count, setCount] = useState(0); | |
// count is state variable | |
// setCount is method to update the count. | |
// 0 is the default value of count | |
return ( | |
<button onClick={() => setCount(count + 1)}> Click me </button> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment