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