diff --git a/src/lazy_request_hook.ts b/src/lazy_request_hook.ts index e079d60..6fae4a3 100644 --- a/src/lazy_request_hook.ts +++ b/src/lazy_request_hook.ts @@ -99,7 +99,7 @@ export function useLazyRequest( && isSameRequest && state?.prevVariables && isEqual(state.prevVariables, variables) && state?.prevHeaders && isEqual(state.prevHeaders, headers) - && !handlerConfig?.force + && handlerConfig?.force === false ) { return Promise.resolve(state.data); } diff --git a/src/request_hook.ts b/src/request_hook.ts index 485f223..9cc056f 100644 --- a/src/request_hook.ts +++ b/src/request_hook.ts @@ -25,7 +25,9 @@ export function useRequest( React.useEffect( () => { if (!skip) { - handler(); + handler({ + force: false, + }); } }, [skip, handler] diff --git a/target/lazy_request_hook.js b/target/lazy_request_hook.js index 893a708..f5a5acb 100644 --- a/target/lazy_request_hook.js +++ b/target/lazy_request_hook.js @@ -42,7 +42,7 @@ export function useLazyRequest(endpoint, config) { && isSameRequest && (state === null || state === void 0 ? void 0 : state.prevVariables) && isEqual(state.prevVariables, variables) && (state === null || state === void 0 ? void 0 : state.prevHeaders) && isEqual(state.prevHeaders, headers) - && !(handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.force)) { + && (handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.force) === false) { return Promise.resolve(state.data); } const onCompletes = [config === null || config === void 0 ? void 0 : config.onComplete, handlerConfig === null || handlerConfig === void 0 ? void 0 : handlerConfig.onComplete].filter(isFunction); diff --git a/target/request_hook.js b/target/request_hook.js index fcef629..bc5b8c1 100644 --- a/target/request_hook.js +++ b/target/request_hook.js @@ -8,7 +8,9 @@ export function useRequest(endpoint, config) { const skip = React.useMemo(() => { var _a; return (_a = config === null || config === void 0 ? void 0 : config.skip) !== null && _a !== void 0 ? _a : false; }, [config]); React.useEffect(() => { if (!skip) { - handler(); + handler({ + force: false, + }); } }, [skip, handler]); return state;