stein197 / rehook

React hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rehook

A collection of React hooks.

Installation

npm install @stein197/rehook

Hooks

useAsync()

Awaits for the promise to resolve.

function useAsync<T, U>(promise: Promise<T>): UsePromise<T, U, false>;

Gets a function that must return a promise and calls it on demand, which starts the process of resolving the promise.

function useAsync<T, U>(cb: () => Promise<T>): UsePromise<T, U, true>;

useBoolean()

Creates a boolean that can be toggled, switched, set.

function useBoolean(init: boolean): UseBooleanReturn;

useForce()

Forces rerender.

function useForce(): () => void;

usePrevious()

Saves the previous value.

function usePrevious<T>(value: T): T;

useImage()

Loads an image.

function useImage(url: string): UseResourceReturn;

useScript()

Loads a script.

function useScript(url: string): UseResourceReturn;

useStylesheet()

Loads a stylesheet.

function useStylesheet(url: string): UseResourceReturn;

NPM script

  • clean. Delete all generated files
  • build. Build the project
  • test. Run unit tests

About

React hooks

License:MIT License


Languages

Language:TypeScript 100.0%