Last active
March 16, 2023 23:02
-
-
Save D-Maher/3658ed65f67c7368f027aeb4e02de22f to your computer and use it in GitHub Desktop.
React component that uses a custom hook
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 from "react"; | |
import useCounter from "../hooks/useCounter"; | |
function CounterWithHook() { | |
const [count, increment, decrement] = useCounter(); | |
return ( | |
<div> | |
<p>Count: {count}</p> | |
<button onClick={increment}>Increment</button> | |
<button onClick={decrement}>Decrement</button> | |
</div> | |
); | |
} | |
export default CounterWithHook; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment