Skip to content
/ hooks Public

A collection of custom React hooks to simplify your development process.

Notifications You must be signed in to change notification settings

itokun99/hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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:

  1. Fork this repository.
  2. Create a new feature branch (git checkout -b new-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin new-feature).
  5. 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!

About

A collection of custom React hooks to simplify your development process.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published