Skip to content

Instantly share code, notes, and snippets.

@paulodutra
Created August 23, 2023 13:32
Show Gist options
  • Save paulodutra/cad387074bd6f51b9998c59fd37db919 to your computer and use it in GitHub Desktop.
Save paulodutra/cad387074bd6f51b9998c59fd37db919 to your computer and use it in GitHub Desktop.
Example using useState with parameter to other component - 1/2
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