Last active
October 31, 2020 21:01
-
-
Save Patrick-DS/fdd08b695d0c46ac2c07f0b1d9c74df0 to your computer and use it in GitHub Desktop.
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
// CountingButton.js | |
import React from "react" | |
const CountingButton = ({ onClick, count }) => ( | |
<button onClick={onClick}> | |
{`You clicked me ${count} times!`} | |
</button> | |
) | |
export default CountingButton | |
// someOtherFile.js | |
import React, { useState, useEffect } from "react" | |
import CountingButton from "./CountingButton" | |
const ExampleComponent = () => { | |
const [count, setCount] = useState(0) | |
const increaseCount = () => setCount(count+1) | |
return <CountingButton onClick={increaseCount} count={count} /> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment