• The hook version of shallowRef from @vue/reactivity. In addition to values accepted by shallowRef, you can also pass an initializer function returning the value.

    This hook version allows the ref to be created when the component first renders, then cached for future re-renders. If you pass in an initializer function, it will only be called on first render.


    Shallow version of ().

    Example

    // Inside a function component:
    const state = useShallowRef({ count: 1 })

    // does NOT trigger change
    state.value.count = 2

    // does trigger change
    state.value = { count: 2 }

    See

    https://vuejs.org/api/reactivity-advanced.html#shallowref

    Type Parameters

    • T

    Parameters

    • initialValue: T | (() => T)

      The "inner value" for the shallow ref, or a function that returns the inner value.

    Returns ShallowRef<T>

Generated using TypeDoc