/** * useMounted Hook * * A hook that provides a ref and a mounted state for components. This hook is useful * for tracking when a component is mounted in the DOM and getting a reference to the DOM element. * * The hook returns an object with: * - ref: An observable reference to the DOM element (uses external ref if provided, otherwise creates a new one) * - isMounted: A memoized observable boolean indicating if the element is mounted * - mount: A comment node used for debugging mount operations (only when no external ref is provided) * * @module useMounted */ import { Observable } from '../soby'; /** * useMounted Hook * * Provides a ref and a mounted state for components. * - If an external ref is provided, it will be used * - If no ref is provided, a new one will be created internally * - The mount property provides a comment node for debugging (only when no external ref is provided) * * @template T - The type of HTMLElement * @param ref - Optional existing observable ref to use * @returns Object containing ref, isMounted, and mount properties * * @example * ```tsx * // Using internally created ref * const { ref, isMounted } = useMounted() * * useEffect(() => { * if ($$(isMounted)) { * console.log('Component is mounted') * } * }) * * return
Hello World
* ``` * * @example * ```tsx * // Using externally provided ref * const myRef = $() * const { isMounted } = useMounted(myRef) * * return
Hello World
* ``` * * @example * ```tsx * // With debugging enabled and internal ref, a comment node will be created to track mount * const { ref, isMounted, mount } = useMounted() * * return ( * <> * {mount} *
Hello World
* * ) * ``` */ export declare function useMounted(ref?: Observable): { ref: Observable; isMounted: import("soby/dist/types").ObservableReadonly; mount: import("..").Child; }; //# sourceMappingURL=use_mounted.d.ts.map