16 lines
339 B
TypeScript
16 lines
339 B
TypeScript
|
import React, { DependencyList, EffectCallback, useEffect } from "react";
|
||
|
|
||
|
export const useNoInitialEffect = (
|
||
|
effect: EffectCallback,
|
||
|
deps: DependencyList
|
||
|
) => {
|
||
|
const initial = React.useRef(true);
|
||
|
useEffect(() => {
|
||
|
if (initial.current) {
|
||
|
initial.current = false;
|
||
|
return;
|
||
|
}
|
||
|
return effect();
|
||
|
}, deps);
|
||
|
};
|