0.7.1 • Published 3 years ago

@talves/use-previous v0.7.1

Weekly downloads
17
License
MIT
Repository
github
Last release
3 years 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

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago