useHooks is currently down!
useHooks

Contributing

Reporting Issues

If you encounter any issues while using useHooks, please report them on the GitHub Issues page. When reporting an issue, please provide as much detail as possible, we already made a template for you to use, so you don't have to worry about that.

Clone the Repository

git clone https://github.com/Pyr33x/useHooks.git

Folder Structure

index.ts
index.ts
useHook.ts
useHook.demo.tsx
useHook.test.ts
tsup.config.ts
package.json

Adding Hooks

You can add a new hook by following these steps:

  1. Create a new folder in the src folder with the name of the hook.
  2. Create a new file in the folder with the name of the hook.
  3. Create a new file in the folder with the name of the hook and the extension .demo.tsx.
  4. Create a new file in the folder with the name of the hook and the extension .test.ts.
  5. Create a new file in hook folder index.ts.
  6. Export the hook in the index.ts file.
  7. Export the hook from src/index.ts.

Writing Tests

Here's a simple example of how to add tests for a hook, you can check docs for more information.

src/useTest/useTest.test.ts
import { renderHook, act } from "@testing-library/react";
import { useTestHook } from "./useTestHook";
 
describe("useTestHook", () => {
  it("should return something", () => {
    const { result } = renderHook(() => useTestHook());
    expect(result.current).toBe("something");
  }});
Hook Names

Hook names must be same as the file and folder name, and all of them must be prefixed with use.

Actions

By opening a pull request, Github Workflows will run the following actions:

  1. Run build to bundle the entire hooks.
  2. Run test to run the hooks.

You must get passing from actions so we can merge your pull request.

On this page