Skip to content

fix: Allow retry to be passed in and override default behavior for useRequest and useRequests #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/redux-query-react/src/hooks/use-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ const useRequest = (
const transformQueryConfig = useConstCallback(
(queryConfig: ?QueryConfig): ?QueryConfig => {
return {
// Note: This is the default retry option. Retry can and should be overridden by passed in configuration.
retry: true,
...queryConfig,
unstable_preDispatchCallback: finishedCallback,
retry: true,
};
},
);
Expand Down
3 changes: 2 additions & 1 deletion packages/redux-query-react/src/hooks/use-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ const useRequests = (
const transformQueryConfig = useConstCallback(
(queryConfig: ?QueryConfig): ?QueryConfig => {
return {
// Note: This is the default retry option. Retry can and should be overridden by passed in configuration.
retry: true,
...queryConfig,
unstable_preDispatchCallback: finishedCallback(getQueryKey(queryConfig)),
retry: true,
};
},
);
Expand Down
22 changes: 8 additions & 14 deletions packages/redux-query-react/src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// @flow

import connectRequest from './components/connect-request';
import Provider from './components/Provider';
import useMutation from './hooks/use-mutation';
import useRequest from './hooks/use-request';
import useRequestOnDemand from './hooks/use-request-on-demand';
import useRequests from './hooks/use-requests';

export { connectRequest };
export { Provider };
export { useMutation };
export { useRequest };
export { useRequestOnDemand };
export { useRequests };
export { default as connectRequest } from './components/connect-request';
export { default as Provider } from './components/Provider';
export { default as useMutation } from './hooks/use-mutation';
export { default as useQueryState } from './hooks/use-query-state';
export { default as useQueriesState } from './hooks/use-queries-state';
export { default as useRequest } from './hooks/use-request';
export { default as useRequestOnDemand } from './hooks/use-request-on-demand';
export { default as useRequests } from './hooks/use-requests';