Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
React.useEffect(() => {
// Localization only changes in Android (in iOS the app is restarted) and
// will only happen when the app comes back into the foreground
if (Platform.OS !== "android" || appState !== "active") return;
Localization.getLocalizationAsync()
.then(({ locale }) => setLocale(locale || "en"))
.catch(() => {});
}, [appState]);