npm

use-subsequent-effect
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

use-subsequent-effect

A use(Layout)Effect variant hook that skips the initial render.

build npm gzipped license

Installation

Skypack

import { useSubsequentEffect } from "https://cdn.skypack.dev/use-subsequent-effect"

Yarn

yarn add use-subsequent-effect

npm

npm install use-subsequent-effect

Usage

Import useSubsequentEffect, useSubsequentLayoutEffect or useSubsequentIsomorphicLayoutEffect.

import { useSubsequentEffect } from "use-subsequent-effect"

Use it as a drop-in use(Layout)Effect replacement.

useSubsequentEffect(() => {
  dependency.update()

  return () => {
    dependency.clean()
  }
}, [dependency])

ESLint

If you are using eslint-plugin-react-hooks, there's no need to specify a custom additionalHooks list. The react-hooks/exhaustive-deps rule already works out-of-the-box on all effect hooks (/Effect($|[^a-z])/g).

Package Sidebar

Install

npm i use-subsequent-effect

Weekly Downloads

16

Version

1.2.1

License

MIT

Unpacked Size

28.6 kB

Total Files

38

Last publish

Collaborators

  • marcbouchenoire