diff --git a/src/frontend/hooks/persistedState/usePersistedLocale.ts b/src/frontend/hooks/persistedState/usePersistedLocale.ts index 2d4c2cad0..c541ceaa2 100644 --- a/src/frontend/hooks/persistedState/usePersistedLocale.ts +++ b/src/frontend/hooks/persistedState/usePersistedLocale.ts @@ -9,7 +9,10 @@ type LocaleSlice = { }; const localeSlice: StateCreator = (set, get) => ({ - locale: getSupportedLocale(getLocales()[0].languageTag) || 'en', + // We can use this non-null assertion with `getLocales()` because, according + // to [the docs][1], the result is "guaranteed to contain at least 1 element." + // [1]: https://github.com/expo/expo/blob/5585320eec9271038cd7c672b4cf9f0e945ca658/packages/expo-localization/src/Localization.ts#L123 + locale: getSupportedLocale(getLocales()[0]!.languageTag) || 'en', setLocale: newlocale => set({locale: newlocale}), });