@itokun99/hooks
v1.0.0
Published
Usefull react hooks for react app
Downloads
15
Maintainers
Readme
@itokun99/hooks
A collection of custom React hooks to simplify your development process.
Installation
To install this package, run the following command:
npm install @itokun99/hooks
Usage
Here's how to use this package in your project.
Importing Hooks
import { useForm } from "@itokun99/hooks";
Example Hook Usage: useForm
Below is an example of how to use the useForm
hook included in this package.
import React from "react";
import { useForm } from "@itokun99/hooks";
function ExampleForm() {
const { values, handleChange, handleSubmit } = useForm({
initialValues: { username: "", email: "" },
onSubmit: (formValues) => {
console.log("Form submitted with values:", formValues);
},
});
return (
<form onSubmit={handleSubmit}>
<div>
<label>Username:</label>
<input
type="text"
name="username"
value={values.username}
onChange={handleChange}
/>
</div>
<div>
<label>Email:</label>
<input
type="email"
name="email"
value={values.email}
onChange={handleChange}
/>
</div>
<button type="submit">Submit</button>
</form>
);
}
export default ExampleForm;
Available Hooks
useForm
A custom hook for managing form state and handling form submissions.
Parameters:
initialValues
(object): The initial values of the form fields.onSubmit
(function): The function to call when the form is submitted.
Returns:
values
(object): The current form values.handleChange
(function): A function to handle input changes.handleSubmit
(function): A function to handle form submission.
useAnotherHook
A description of what useAnotherHook
does.
Returns:
value
(any): Some value.setValue
(function): A function to update the value.
Contributing
If you would like to contribute to this project, please follow these steps:
- Fork this repository.
- Create a new feature branch (
git checkout -b new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin new-feature
). - Create a Pull Request.
License
This package is licensed under the MIT License.
For more information, visit the GitHub repository.
Feel free to let me know if there are any additional changes you'd like to make!