🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@etheryte/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@etheryte/react-hooks

Common React hooks for worry-free state and control flow management.

2.0.4
latest
Source
npm
Version published
Weekly downloads
731
37.41%
Maintainers
1
Weekly downloads
 
Created
Source

@etheryte/react-hooks

Common React hooks for worry-free state and control flow management.

Installation

yarn add @etheryte/react-hooks

Hooks

useUpdateEffect(effect, dependencies?)

Use effect on every update except the initial render. Accepts the same parameters as React.useEffect().

useAsyncEffect(asyncEffect, dependencies?)

React.useEffect() with async helpers. The effect is passed a function isStale() which returns a boolean value indicating whether the dependencies have changed between the start of the async effect and the moment you call it.

useAsyncEffect(async (isStale) => {
  const result = await longAsyncRequest();
  // If the dependencies changed between the request start and now, discard the result
  if (isStale()) {
    return;
  }
  setFoo(result);
}, dependencies);

useAsyncUpdateEffect(asyncEffect, dependencies?)

Use async effect on every update except the initial render. Accepts the same parameters as useAsyncEffect(). The effect is passed a function isStale() which returns a boolean value indicating whether the dependencies have changed between the start of the async effect and the moment you call it.

useAsyncState(getter, dependencies?)

A state variable like React.useState() that fetches its value from an async source whenever the dependencies change. Stale values are handled automatically.

const value = useAsyncState(async () => {
  if (condition) {
    return undefined;
  }
  return longAsyncRequest();
}, dependencies);

Keywords

react

FAQs

Package last updated on 28 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts