Shadcn Hooks

useMount

A hook to run a function when the component mounts

Installation

npx shadcn@latest add @shadcnhooks/use-mount

API

type MountCallback = EffectCallback | (() => Promise<void | (() => void)>)

/**
 * A hook to run a function when the component mounts
 * @param fn - The function to run when the component mounts
 * @returns The function to run when the component mounts
 */
export function useMount(fn: MountCallback): void

Credits

Last updated on

On this page