expo-localization fails with Expo 30.0.1

I’m trying to use expo-localization, but it’s failing with the error

undefined is not an object (evaluating '_ref.locale')

which occurs in the _syncLocals function in LocalizationModule when called from its constructor.

To use it I simply did

yarn add expo-localization

in my non-ejected Expo app, then added

import { Localization } from 'expo-localization';

to my App.js file.

Is it necessary to eject and add native libraries to just get the current locale? The docs for Localization in Expo are very unclear on this.

expo-localization is introduced in v31. I would recommend you update the expo version. Then you can use the lib with:

import { Localization } from 'expo'
// or
import { Localization } from 'expo-localization'

But if you don’t want to do that you could also use the soon-to-be-deprecated:

import { DangerZone } from 'expo';
const { Localization } = DangerZone;

Which you can learn more about in the docs: https://docs.expo.io/versions/v30.0.0/sdk/localization

1 Like

Thanks, this solves my problem!

It would be good to have the minimum version listed in each document, as it’s fairly confusing. For example, the npm package (expo-localization - npm) talks about installing CocoaPods, which of course makes no sense if you have not ejected, and suggests that this only works with ejected apps.

If a feature can work with both ejected and non-ejected apps, it should call out that you do not have to eject to use it.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.