Last active
November 3, 2019 01:21
-
-
Save Falconiere/ba231888b3ddc9b0fff320d260d0d554 to your computer and use it in GitHub Desktop.
A simple component after hooks
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, { Fragment, useState } from 'react' | |
export default function SimpleComponent(){ | |
const [counter, setCounter] = useState(0) | |
function handleOnClick(e){ | |
e.preventDefault() | |
setCounter(counter + 1) | |
} | |
return ( | |
<Fragment> | |
<h1>Counter: {counter} </h1> | |
<button onClick={handleOnClick}> Click me! </button> | |
</Fragment> | |
) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment