Created
October 29, 2018 00:01
-
-
Save haldarmahesh/3208f4804e4dcb92e632556b003ef2f2 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, { useState, useEffect } from 'react'; | |
export default function counterHook() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
document.title = "Count is " + count; | |
}); | |
return ( | |
<div> | |
<div> | |
<button onClick={() => setCount(count + 1)}> + Increment</button> | |
<button onClick={() => setCount(count - 1)}> - Decrement</button> | |
</div> | |
<div> | |
Current: {count} | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment