Skip to content

Instantly share code, notes, and snippets.

@cbrannen9a
Last active November 12, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbrannen9a/6c61c797db9a122017dd10184caaca6e to your computer and use it in GitHub Desktop.
Save cbrannen9a/6c61c797db9a122017dd10184caaca6e to your computer and use it in GitHub Desktop.
Example React Hook
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You have written {count} hooks</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
export default Example;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment