Created
August 23, 2023 13:32
-
-
Save paulodutra/cad387074bd6f51b9998c59fd37db919 to your computer and use it in GitHub Desktop.
Example using useState with parameter to other component - 1/2
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 } from 'react'; | |
import { Button } from './Button'; | |
function App() { | |
const [total, setTotal] = React.useState(0); | |
return ( | |
<div> | |
<p>Total: {total}</p> | |
<Button increment={setTotal} /> | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment