0.7.1 • Published 11 months ago

@talves/use-previous v0.7.1

Weekly downloads
17
License
MIT
Repository
github
Last release
11 months ago

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm install --save @talves/use-previous

OR

yarn add @talves/use-previous

Usage

/* using react ^17.0.1 */
import { useEffect } form 'react'
import { usePrevious } from '@talves/use-previous'

function ourFunctionalComponent({ value = 0 }) {
  const [state, setState] = React.useState({ count: value })
  const previousValue = usePrevious(value)

  useEffect(() => {
    setState({ count: value })
  }, [value])

  // prevousState is now the last value
  ...
}

NOTE: This is a module package library for react with jsx. The choice is to resolve the export of main to src/index.js. There is a commonjs version in dist/cjs/index.js if someone needed.

Other Solutions

Plenty of other usePrevious hooks out there.

0.7.1

11 months ago

0.7.0

11 months ago

0.6.0

11 months ago

0.5.1

12 months ago

0.5.0

12 months ago

0.4.0

12 months ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago