A collection of reusable custom React hooks to simplify state management, performance optimization, and common UI interactions. Built with React + TypeScript.
- ✅ Debounce Hook (
useDebounce) - ✅ Throttle Hook (
useThrottle) - ✅ More hooks coming soon...
Clone the repo and install dependencies:
git clone https://github.com/root2ja/custom-react-hooks.git
cd custom-react-hooks
npm installDebounces an input value with a specified delay.
import { useDebounce } from "./hooks/useDebounce";
import { useState } from "react";
function SearchComponent() {
const [searchTerm, setSearchTerm] = useState("");
const debouncedSearch = useDebounce(searchTerm, 500);
return (
<input
type="text"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
placeholder="Search..."
/>
);
}import { useThrottle } from "./hooks/useThrottle";
import { useState } from "react";
function ScrollLogger() {
const [position, setPosition] = useState(0);
const throttledPosition = useThrottle(position, 300);
return <div>Current Scroll Position: {throttledPosition}</div>;
}To run the project locally:
npm startTo build the project:
npm run buildWant to add more hooks? Feel free to fork the repo and submit a PR! 😊
- Fork this repo
- Clone your fork
git clone https://github.com/roo2ja/custom-react-hooks.git
- Create a new branch
git checkout -b feature-new-hook
- Make your changes & commit
git add . git commit -m "Added new custom hook: useExample"
- Push to GitHub & create a PR
git push origin feature-new-hook
⭐ If you found this project useful, give it a star on GitHub! 💬 Feel free to open an issue if you have ideas or suggestions.