@kwiz/fluentui
Version:
KWIZ common controls for FluentUI
27 lines (26 loc) • 1.26 kB
TypeScript
import { HTMLAttributes, MutableRefObject, SetStateAction } from "react";
/** Empty array ensures that effect is only run on mount */
export declare const useEffectOnlyOnMount: any[];
type stateExOptions<ValueType> = {
onChange?: (newValue: ValueType, isValueChanged: boolean) => ValueType;
skipUpdateIfSame?: boolean;
name?: string;
};
/** set state on steroids. provide promise callback after render, onChange transformer and automatic skip-set when value not changed */
export declare function useStateEX<ValueType>(initialValue: ValueType, options?: stateExOptions<ValueType>): [
ValueType,
(newValue: SetStateAction<ValueType>) => Promise<ValueType>,
MutableRefObject<ValueType>
];
/** use a ref, that can be tracked as useEffect dependency */
export declare function useRefWithState<T>(initialValue?: T, stateOptions?: stateExOptions<T>): {
/** ref object for getting latest value in handlers */
ref: MutableRefObject<T>;
/** for useEffect dependency */
value: T;
/** for setting on element: ref={e.set} */
set: (newValue: T) => void;
};
/** return props to make div appear as clickable, and accept enter key as click */
export declare function useClickableDiv(): HTMLAttributes<HTMLDivElement>;
export {};