@reactivers/hooks Github link@reactivers/hooks NPM link

usePrevious

Introduction

  • usePrevious tracks values from the last render in react component.
  • Can track any value from last render.
  • You can get any value from previous render easily so you can know what is changed
const prev = usePrevious(current);

Getting Started

  • You need to import usePrevious

From Collection

import { usePrevious } from "@reactivers/hooks";

From Package

import { usePrevious } from "@reactivers/use-previous";

Interfaces

Props

interface IUsePreviousProps {

    //To be tracked value
    current: any;
}

Returns

interface IUsePreviousReturns {
    
    //Previous value of tracking value
    previous: any;
}

Example

Example Preview - CodeSandbox