You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering a critical issue with my Expo app that uses React Query. This issue only occurs in production builds, not in development. The app crashes with an EXC_BAD_ACCESS exception.
getData request is made on the first screen of the app, and the same RQ hook is used in a modal on another page (so the same cached data is used given the data is associated with the same Query Key)
This code caused the app to crash when navigating to the modal upon which the request is made AFTER the stale time has ended.
Resolution Attempt
I removed the code regarding expo-contacts. The error occurred less frequently although the app still crashed.
Played around with the stale time. If the data became stale sooner, the app would crash sooner.
Based on suggestions from other developers, I modified the code as follows:
// React Query useQuery hook where enabled = false (so it doesn't automatically fetch)
const { refetch } = getData({ enabled: false });
useEffect(() => {
const fetchContacts = async () => {
const contacts = await Contacts.getContactsAsync();
const data = await refetch().data;
// manipulating state with <data> and <contacts>
}
fetchContacts();
}, []);
This change resolved the issue, but I am still unclear why the original code did not work and led to the crash.
Request for Assistance
I am looking for insights into why this issue might be occurring and whether there are best practices or known issues with React Query in React Native apps. I don't think this issue was related to the lifecycle events on iOS devices because I would never exist the app, still wait for the staletime to elapse, and the app would still crash when navigating onto the modal upon which a fresh request is made.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I am encountering a critical issue with my Expo app that uses React Query. This issue only occurs in production builds, not in development. The app crashes with an EXC_BAD_ACCESS exception.
Code + Problem Details
getData
request is made on the first screen of the app, and the same RQ hook is used in a modal on another page (so the same cached data is used given the data is associated with the same Query Key)This code caused the app to crash when navigating to the modal upon which the request is made AFTER the stale time has ended.
Resolution Attempt
expo-contacts
. The error occurred less frequently although the app still crashed.This change resolved the issue, but I am still unclear why the original code did not work and led to the crash.
Request for Assistance
I am looking for insights into why this issue might be occurring and whether there are best practices or known issues with React Query in React Native apps. I don't think this issue was related to the lifecycle events on iOS devices because I would never exist the app, still wait for the staletime to elapse, and the app would still crash when navigating onto the modal upon which a fresh request is made.
Thank you for your time and assistance!
Beta Was this translation helpful? Give feedback.
All reactions