-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[bug][react-native] crash since 3.34.7+ - No QueryClient set, use QueryClientProvider to set one #3153
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
Comments
The only change in 3.34.6 was something stylistic in the devtools, so it's unlikely that this caused it: v3.34.5...v3.34.6 please show all involved components, especially |
This is my import { useQuery } from 'react-query';
import { AxiosResponse } from 'axios';
import { ApiService } from 'app/services/ApiService';
// import { useStore } from 'app/store';
/**
*
* @returns Deals with my request details api
* Caching handled by react query
*/
export const GetUserDetails = () => {
const staffRequestService = ApiService.createInstance();
// const userId = useStore(state => state.userId);
return useQuery(['UserDetails'], async () => {
const response: AxiosResponse = await staffRequestService.getCharacters();
return response.data;
});
}; Which is being called in my Home Component (this first route opened by react-navigation). And this is my Home Component import React from 'react';
import { View, FlatList, RefreshControl } from 'react-native';
import { useStore } from 'app/store';
import styles from './styles';
import { GetUserDetails } from 'app/services/react-query/queries/user';
const Home: React.FC = () => {
const setIsLoggedIn = useStore((state) => state.setIsLoggedIn);
const { isLoading, isFetching, data = { results: [] } } = GetUserDetails();
const onLogOut = () => {
setIsLoggedIn(false);
};
const renderItem = ({ item }) => <View />;
return (
<View style={styles.container}>
<FlatList
data={data.results}
renderItem={renderItem}
keyExtractor={(item) => item.id}
refreshControl={
<RefreshControl
refreshing={isLoading || isFetching}
onRefresh={() => {}}
/>
}
/>
</View>
);
};
export default Home; P.S: Sorry, I upgraded from 0.34.5 to 0.34.7. |
Could also be related: #3069 Sounds exactly like my issue, but he closed it without further notice unfortunately. |
Are you sure that Home is inside a QueryClientProvider? You haven't shown that as far as I can see |
@TkDodo yes, it is a import and component of |
this seems invalid. Either make it a custom hook, or render GetUserDetails as a react component. |
@TkDodo I found the issue. I am using a Yarn Workspace (monorepo) and Lerna. react-query was updated in packages/expo but not packages/app (usally you should only install in one workspace but the only way to get autocomplete working was to install it in every package [I've double confirmed this with vscode devs] and this was the error. The type error is gone and also the crash is gone. Not sure what was happening internally... Sorry for bothering you! |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
I was running react-query with 3.34.5 for a couple of weeks and everything worked flawlessly on React Native.
Since 3.34.7, my app is crashing with following error:
Furthermore, I get this type error now:
My
QueryClientProvider
is looking like this:Your Example Website or App
Steps to reproduce
I am importing my client like so:
and the content of my service file is
My
QueryClientProvider
is looking like this:Expected behavior
Should not crash.
No issues if I downgrade to 3.34.5.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Additional context
The error triggers, as soon as this function calls:
The text was updated successfully, but these errors were encountered: