Files
portainer/app/react/hooks/useUpdateEffect.ts
T
Cara Ryan 6a30138b3c feat(home): environment home page ui improvements to highlight groups [C9S-23] (#2487)
Signed-off-by: Bernard Setz <bernard.setz@portainer.io>
Co-authored-by: bernard-portainer <bernard.setz@portainer.io>
Co-authored-by: Ali <83188384+testA113@users.noreply.github.com>
Co-authored-by: Yajith Dayarathna <yajith.dayarathna@portainer.io>
Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com>
Co-authored-by: andres-portainer <91705312+andres-portainer@users.noreply.github.com>
Co-authored-by: Josiah Clumont <josiah.clumont@portainer.io>
Co-authored-by: Dakota Walsh <101994734+dakota-portainer@users.noreply.github.com>
2026-04-29 14:59:39 +12:00

21 lines
513 B
TypeScript

import { useEffect, useRef } from 'react';
/**
* Like `useEffect`, but skips the callback on the initial render.
* Only runs when a dependency changes after the component has mounted.
*/
export function useUpdateEffect(
fn: () => void,
deps: React.DependencyList
): void {
const isFirstRender = useRef(true);
useEffect(() => {
if (isFirstRender.current) {
isFirstRender.current = false;
return;
}
fn();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
}