vue-lynx / unref

Function: unref()

function unref<T>(ref): T

Returns the inner value if the argument is a ref, otherwise return the argument itself. This is a sugar function for val = isRef(val) ? val.value : val.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
refMaybeRef<T> | ComputedRef<T>Ref or plain value to be converted into the plain value.

Returns

T

Example

function useFoo(x: number | Ref<number>) {
  const unwrapped = unref(x)
  // unwrapped is guaranteed to be number now
}

See

https://vuejs.org/api/reactivity-utilities.html#unref

Defined in

node_modules/.pnpm/@vue+reactivity@3.5.30/node_modules/@vue/reactivity/dist/reactivity.d.ts:509