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