Skip to content

Instantly share code, notes, and snippets.

@cbrannen9a
Created November 12, 2018 17:09
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/b2c1e055eb2e4928936086a1495d49ba to your computer and use it in GitHub Desktop.
Save cbrannen9a/b2c1e055eb2e4928936086a1495d49ba to your computer and use it in GitHub Desktop.
Adding second hook
import React, { useState, useEffect } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
useEffect(() => {
// Update the document title using the browser API
document.title = `You have written ${count} hooks`;
});
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