mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-18 14:38:24 +00:00
16 lines
356 B
TypeScript
16 lines
356 B
TypeScript
import { DependencyList, EffectCallback, useEffect, useRef } from 'react';
|
|
|
|
export const useUpdateEffect = (effect: EffectCallback, deps?: DependencyList) => {
|
|
const isFirstRef = useRef(true);
|
|
|
|
if (isFirstRef.current) {
|
|
isFirstRef.current = false;
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (!isFirstRef.current) {
|
|
return effect();
|
|
}
|
|
}, deps);
|
|
};
|