Skip to content

Instantly share code, notes, and snippets.

@night-fury-rider
Last active March 23, 2021 03:18
Show Gist options
  • Save night-fury-rider/048e6e831d9fb3e670119d65c9e127f4 to your computer and use it in GitHub Desktop.
Save night-fury-rider/048e6e831d9fb3e670119d65c9e127f4 to your computer and use it in GitHub Desktop.
React Hook - useState
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