kumar-rahul-lib
v1.0.0
Published
`kumar-rahul-lib` is a simple React library that provides a custom hook for managing a counter (`useCounter`) and a reusable `Button` component. This library is created by **Kumar Rahul**.
Readme
Kumar Rahul's Library
kumar-rahul-lib is a simple React library that provides a custom hook for managing a counter (useCounter) and a reusable Button component. This library is created by Kumar Rahul.
Installation
To install the library, use npm:
npm install kumar-rahul-libComponents and Hooks
1. useCounter Hook
The useCounter hook allows you to easily manage a counter state with increment and decrement functions.
Usage:
import { useCounter } from 'kumar-rahul-lib';
function App() {
const { count, increament, decreament } = useCounter();
return (
<>
<button onClick={increament}>+</button>
<h1>{count}</h1>
<button onClick={decreament}>-</button>
</>
);
}2. Button Component
The Button component is a styled button with customizable text and click functionality.
Usage:
import { Button } from 'kumar-rahul-lib';
function App() {
const handleClick = () => {
alert('Button clicked!');
};
return (
<Button onClick={handleClick}>Click Me</Button>
);
}Example Usage
Below is a simple example demonstrating how to use the Button component and useCounter hook together:
import { Button, useCounter } from 'kumar-rahul-lib';
import './App.css';
function App() {
const { count, increament, decreament } = useCounter();
return (
<>
<Button onClick={increament}>+</Button>
<h1>{count}</h1>
<Button onClick={decreament}>-</Button>
</>
);
}
export default App;License
This library is open-source and available under the MIT License.
