A lightweight and easy-to-use collection of 15+ custom React hooks, designed to help you build efficient and scalable React applications. This package is built with JavaScript and comes with pre-written test scripts to ensure reliability.
- 15+ Custom React Hooks: A collection of useful hooks to manage state, effects, and more.
- Lightweight: Minimal dependencies and a small footprint.
- Easy to Implement: Quick setup with straightforward usage.
- Built with JavaScript: No need for TypeScript to use, though it can easily be integrated.
- Pre-written Tests: Ensure the reliability of each hook with included test scripts.
- Well-documented: Clear documentation for each custom hook, along with usage examples.
You can install this package via npm:
npm install react-hook-granth
Or if you are using Yarn:
yarn add react-hook-granth
Once installed, you can import the hooks from the library and start using them in your React components.
import { useCounter } from 'react-hook-granth';
const Counter = () => {
const { count, increment, decrement, reset } = useCounter(0);
return (
<div>
<h1>{count}</h1>
<button onClick={increment}>Increment</button>
<button onClick={decrement}>Decrement</button>
<button onClick={reset}>Reset</button>
</div>
);
};
Here’s a list of the hooks available in this package:
useCounter
useLocalStorage
usePrevious
useDebounce
useEventListener
useWindowSize
- And many more...
This package comes with pre-written test scripts to ensure each hook works as expected. To run the tests, use the following command:
npm test
This will run the test suite using Vitest, the testing framework used in this package.
We welcome contributions! Feel free to open issues or submit pull requests with improvements, bug fixes, or additional hooks.
To contribute:
- Fork the repository.
- Clone your fork and create a new branch.
- Make your changes and write tests for new functionality.
- Submit a pull request with a description of the changes.
This project is licensed under the MIT License - see the LICENSE file for details.
- Author: Yuvraj Karna
- Personal Website: Visit
- Email: yuvrajkarna.code@gmail.com
For questions, feel free to reach out or open an issue in the repository.
- Features: Highlights the main benefits of the package (15+ hooks, lightweight, easy to implement).
- Installation: Instructions on how to install the package using npm or Yarn.
- Usage: A simple example showing how to use the hooks.
- Available Hooks: A list of hooks that are part of the library (expandable with your specific hooks).
- Running Tests: Information about the test script and how to run them using Vitest.
- Contributing: A section for developers who want to contribute to the package.
- License: License information.
Feel free to update the sections as needed, such as adding specific details for each custom hook and personal contact details.