useMount()
The
useMount() hook is a semantic alias for useEffect(fn, []). It ensures that the provided callback runs strictly once when the component is first mounted to the DOM.Import
typescript
Usage
Toggle the component to trigger the useMount hook.
Component is not in DOM
Component.tsx
API
Arguments
effect– EffectCallback The function to execute on mount. It can optionally return a cleanup function.
Returns
This hook returns
void.