-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[TypeScript] ReactQueryConfigProvider type miss match #542
Comments
Have you tried in the latest version? |
@thebuilder tried 1.5.5 and still getting the same warning Looking at the typings, the error in config was always fall back to
|
I think that should be fine. It expects an instance of the config type, which you are providing. |
@thebuilder here is a link to the a codesandbox with the error https://codesandbox.io/s/cocky-ride-zg0od You cant pass the error type to |
You're right. Haven't had to use a generic on JSX before. Not pretty - might wan't to also add documentation for this use case. But in that case, then yes - this would be the correct way. <ReactQueryConfigProvider
<AxiosError>
config={reactQueryConfig}
>
...
</ReactQueryConfigProvider> |
Rewriting the type into this, should solve it: export function ReactQueryConfigProvider<TError = Error>(props: {
config?: ReactQueryProviderConfig<TError>;
children?: React.ReactNode;
}): React.ReactElement; |
This fixes TanStack#542 by allowing the `<ReactQueryConfigProvider>` to get the generic error type.
This fixes #542 by allowing the `<ReactQueryConfigProvider>` to get the generic error type.
🎉 This issue has been resolved in version 1.5.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@pete-redmond-cko has this Is it supposed to override the type of error returned by May I ask what form of
|
@mustafawm yeah it worked. It only overrides the type of Error in My use case was to handle retry logic on the config provider so I didnt have to do it on every const reactQueryConfig: ReactQueryProviderConfig<AxiosError> = {
refetchAllOnWindowFocus: false,
refetchOnWindowFocus: false,
retry: (failureCount, error) => {
if (is404Error(error)) {
return false;
}
return failureCount > 2;
},
};
<ReactQueryConfigProvider<AxiosError> config={reactQueryConfig}>...<../> |
Thanks for your quick reply @pete-redmond-cko 🙏. Will start passing error type to |
I noticed that use can pass the type of error to the
ReactQueryProviderConfig
interface, however theReactQueryConfigProvider
does not except theTError
so it sets the error in config to beError
(the default).I am getting a type error when trying to use a
AxiosError
in the config.Shouldn't the ReactQueryConfigProvider take in the Error Type?
The text was updated successfully, but these errors were encountered: