Skip to content

Instantly share code, notes, and snippets.

@D-Maher
Last active March 16, 2023 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D-Maher/3658ed65f67c7368f027aeb4e02de22f to your computer and use it in GitHub Desktop.
Save D-Maher/3658ed65f67c7368f027aeb4e02de22f to your computer and use it in GitHub Desktop.
React component that uses a custom hook
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