Created
February 7, 2019 14:41
-
-
Save seanrankin/ca419acdef4161580ef35320ecd3f517 to your computer and use it in GitHub Desktop.
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, { useEffect, useState } from 'react'; | |
export const EffectHook = () => { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
document.title = `You clicked ${count} times`; | |
console.log(`useEffect ${count}`); | |
}); | |
return <button onClick={() => setCount(count + 1)}>Effect Hook {count}</button>; | |
}; | |
export const StateHook = () => { | |
const [count, setCount] = useState(0); | |
return <button onClick={() => setCount(count + 1)}>State Hook {count}</button>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment