mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
22 lines
519 B
TypeScript
22 lines
519 B
TypeScript
import {useEffect, useRef} from 'react';
|
|
|
|
const useEffectAfterFirstRender = (
|
|
cb: React.EffectCallback,
|
|
deps: React.DependencyList
|
|
): void => {
|
|
const firstRender = useRef<boolean>(true);
|
|
|
|
useEffect(() => {
|
|
if (firstRender.current) {
|
|
firstRender.current = false;
|
|
return;
|
|
}
|
|
|
|
cb();
|
|
// Dependencies are explicitly managed and the deps warning is enabled for the custom hook.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, deps);
|
|
};
|
|
|
|
export {useEffectAfterFirstRender};
|