@stein197/rehook
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @stein197/rehook

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

25.8 kB

Total Files

7

Last publish

Collaborators

  • stein197