mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
17 lines
314 B
TypeScript
17 lines
314 B
TypeScript
import { useRef, useEffect } from 'react'
|
|
|
|
const useUpdateEffect: typeof useEffect = (effect, deps) => {
|
|
const isInitialMount = useRef(true)
|
|
|
|
useEffect(
|
|
isInitialMount.current
|
|
? () => {
|
|
isInitialMount.current = false
|
|
}
|
|
: effect,
|
|
deps
|
|
)
|
|
}
|
|
|
|
export default useUpdateEffect
|