Function: useEffectAfterMount()
useEffectAfterMount(
fn,deps?):void
Defined in: use-effect-after-mount.ts:21
A custom React hook that triggers a callback function only after the component has mounted and whenever the specified dependencies change.
This hook is useful in cases where you want to skip the effect on the initial render and only trigger it on subsequent renders when dependencies change.
Parameters
fn
() => void
The callback function to be executed after the component mounts and dependencies change.
deps?
unknown[] = []
An array of dependencies that the effect depends on. When these dependencies change, the callback function will be triggered. If not provided, defaults to an empty array.
Returns
void
Example
useEffectAfterMount(() => {
console.log("This will only log on updates, not on the initial render");
}, [someDependency]);