Warning from react-native on android about long setTimeout #356
-
WarningWhen running react-query with react-native on Android the following warning is emitted. I assume there needs to be a smarter timeout strategy with react-native but not sure what the best solution is.
Warning: Current Workaround:Add the following code to suppress the warning import {YellowBox} from 'react-native';
const App = () => {
//...
useEffect(() => {
YellowBox.ignoreWarnings(['Setting a timer']);
}, []);
//...
} |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Interesting. I honestly didn't know this about React Native. I'll look into some solutions here. |
Beta Was this translation helpful? Give feedback.
-
Preliminary searches are showing that this is a long-running issue with timers on android and that the best solution during all of this time has either been
IMO, suppressing the warning would be fine, since it is just a cache and not a critical operational piece of the app. If the cache doesn't get cleared, then the data will remain in memory until the app is closed and reopened. Not a big deal. And if it does become a big deal, then you have other options. |
Beta Was this translation helpful? Give feedback.
-
Am I understanding this correctly, that on Android the timer won't run in the background, so the cache will just stick around "longer" (until it hits the 5 minute default of being in the foreground)? |
Beta Was this translation helpful? Give feedback.
-
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Setting a timer']); |
Beta Was this translation helpful? Give feedback.
-
YellowBox is deprecated use LogBox instead |
Beta Was this translation helpful? Give feedback.
-
I believe this warning will no longer be shown in upcoming RN 0.65, see: facebook/react-native@480dabd & https://github.com/react-native-community/releases/blob/e0636e5aa858320e9695a9c252849d5c97783507/CHANGELOG.md#removed |
Beta Was this translation helpful? Give feedback.
Preliminary searches are showing that this is a long-running issue with timers on android and that the best solution during all of this time has either been
cacheTime
in React Query to be lower)IMO, suppressing the warning would be fine, since it is just a cache and not a critical operational piece of the app. If the cache doesn't get cleared, then the data will remain in memory until the app is closed and…