Skip to content

Function: useLocalState()

ts
function useLocalState<T>(
  emit: EmitWithUpdateModelValue<T>,
  onUpdateModelValueCamelProp: (
    val: T | T[] | null | undefined,
  ) => void | undefined,
  onUpdateModelValueKebabProp: (
    val: T | T[] | null | undefined,
  ) => void | undefined,
  multiple: Ref<boolean>,
  modelValueRef: Ref<T | T[] | null | undefined>,
  modelValueProp: T | T[] | null | undefined,
  onChange: (
    is: LocalStateModelValue<T>,
    was?: LocalStateModelValue<T>,
  ) => void,
): {
  getLocalState: () => any;
  localState: WritableComputedRef<any, T | T[] | null | undefined>;
  recomputeLocalState: () => void;
  setLocalState: (val: T | T[] | null | undefined) => void;
};

Type Parameters

Type Parameter
T

Parameters

ParameterType
emitEmitWithUpdateModelValue<T>
onUpdateModelValueCamelProp(val: T | T[] | null | undefined) => void | undefined
onUpdateModelValueKebabProp(val: T | T[] | null | undefined) => void | undefined
multipleRef<boolean>
modelValueRefRef<T | T[] | null | undefined>
modelValuePropT | T[] | null | undefined
onChange(is: LocalStateModelValue<T>, was?: LocalStateModelValue<T>) => void

Returns

ts
{
  getLocalState: () => any;
  localState: WritableComputedRef<any, T | T[] | null | undefined>;
  recomputeLocalState: () => void;
  setLocalState: (val: T | T[] | null | undefined) => void;
}
NameTypeDefault value
getLocalState()() => any-
localStateWritableComputedRef<any, T | T[] | null | undefined>-
recomputeLocalState()() => voidrecomputeLocalStateValue
setLocalState()(val: T | T[] | null | undefined) => voidsetLocalStateRefValue