UNPKG
@figliolia/react-hooks
Version:
latest (1.7.3)
1.7.3
1.7.2
1.7.1
1.7.0
1.5.0
1.4.0
1.3.0
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.3
A small collection of simple React Hooks you're probably rewriting on a regular basis
@figliolia/react-hooks
/
dist
/
mjs
/
Hooks
/
useUnmount.js
10 lines
(9 loc)
•
266 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
import
{ useEffect, useRef }
from
"react"
;
export
const
useUnmount
= (
onUnmount
) => {
const
callback =
useRef
(onUnmount); callback.
current
= onUnmount;
useEffect
(
() =>
{
const
{
current
: fn } = callback;
return
() =>
fn
(); }, []); };