cust-hooks-use-previous

This returns the previous value of state while using functional component or any react hook.

Usage no npm install needed!

<script type="module">
  import custHooksUsePrevious from 'https://cdn.skypack.dev/cust-hooks-use-previous';
</script>

README

About

cust-hooks-use-previous gives you the previous value of state in functional component / React hook.

Installation

npm i cust-hooks-use-previous

Importing the hook

import { usePrevious } from 'cust-hooks-use-previous';

Usage

const funFunction =() => { const prevNav = usePrevious(activeNav); const prevSortBy = usePrevious(sortBy); // prevNav will be previous value of activeNav. }