A collection of custom React hooks to simplify your development process.
To install this package, run the following command:
npm install @itokun99/hooks
Here's how to use this package in your project.
import { useForm } from "@itokun99/hooks";
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;
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.
A description of what useAnotherHook
does.
Returns:
value
(any): Some value.setValue
(function): A function to update the value.
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.
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!