Appearance
useDefault
Returns the default value when state is null or undefined.
Demo
</>
value: 100 default: 0
Usage
const [state, setState] = useDefault(0, 100)
const [state, setState] = useDefault(0, 100)
Reference
Type Declarations
export declare function useDefault<T = any>(
defaultValue: T,
initialValue: T
): [Ref<UnwrapRef<T>>, (val: T | ((c: UnwrapRef<T>) => T)) => void]
export declare function useDefault<T = any>(
defaultValue: T,
initialValue: T
): [Ref<UnwrapRef<T>>, (val: T | ((c: UnwrapRef<T>) => T)) => void]