@dxos/react-ui
    Preparing search index...

    Variable useDefaultValueConst

    useDefaultValue: <T>(
        reactiveValue: T | undefined | null,
        getDefaultValue: () => T,
    ) => T

    A custom React hook that provides a stable default value for a potentially undefined reactive value. The defaultValue is memoized upon component mount and remains unchanged until the component unmounts, ensuring stability across all re-renders, even if the defaultValue prop changes.

    Note: The defaultValue is not reactive. It retains the same value from the component's mount to unmount.

    Type declaration

      • <T>(reactiveValue: T | undefined | null, getDefaultValue: () => T): T
      • Type Parameters

        • T

        Parameters

        • reactiveValue: T | undefined | null

          The value that may change over time.

        • getDefaultValue: () => T

        Returns T

        • The reactiveValue if it's defined, otherwise the defaultValue.