Created
November 12, 2018 17:09
-
-
Save cbrannen9a/b2c1e055eb2e4928936086a1495d49ba to your computer and use it in GitHub Desktop.
Adding second hook
This file contains 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, 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