xph-form
Version:
This is a configurable form component that supports React
22 lines (21 loc) • 866 B
TypeScript
/**
* @description 该钩子解决的问题:
* 1、使用了Form.useWatch的FormItem,至少都会触发两次组件更新,导致api首次请求的情况不一致
* 2、每次value的更新,都会导致组件的重新渲染,导致api每次都会请求(处理成当params不一致才重新请求)
* @param api - 请求的api
* @param apiCallback - 请求之后的回调
* @param immediate - 首次是否立即执行apiCallback
* @param params - 请求的参数
* @param isUseWatch - 是否使用了Form.useWatch
*/
interface IUseComonentCacheProps {
api?: (...args: any[]) => Promise<any>;
immediate?: boolean;
params: any;
apiCallback: (...args: any[]) => void;
isUseWatch: boolean;
}
declare const useApiComonentCache: (props: IUseComonentCacheProps) => {
getApiData: () => void;
};
export default useApiComonentCache;