React-native-i18n: Cannot read property 'getLanguages' of undefined

Created on 7 Dec 2017  路  13Comments  路  Source: AlexanderZaytsev/react-native-i18n

Hello guys, i've got this wonderful lib and it works fine except during test

I'm using jest, and i've go this weird error.

    TypeError: Cannot read property 'getLanguages' of undefined

      at Object.<anonymous> (node_modules/react-native-i18n/index.js:12:45)
      at Object.<anonymous> (src/i18n/index.js:1:849)
      at Object.<anonymous> (src/features/login/index.js:5:11)

The app works tho.

@AlexanderZaytsev

Most helpful comment

153 ,I am now working for both android and ios. I was not able to work before because of the operationAutomatic setup with Cocoapods. I guess it may be because pod install failed, but I did not see the error log on the console.

Here are my steps:

1, Created a new project

2, npm install react-native-i18n --save

3, react-native link

4, react-native run-ios/run-android

I did not configure Automatic setup with Cocoapods In ios, it is recommended to update the document, to prevent the user with trouble.
@zoontek

All 13 comments

Same here, one every two runs.

+1

+1

image
Why does this happen?
@AlexanderZaytsev

@giantss Try replacing the function with (don't forget to clean the packager cache):

export const getLanguages = () => RNI18n.getLanguages()

Does it fixes the problem?

+1

153 ,I am now working for both android and ios. I was not able to work before because of the operationAutomatic setup with Cocoapods. I guess it may be because pod install failed, but I did not see the error log on the console.

Here are my steps:

1, Created a new project

2, npm install react-native-i18n --save

3, react-native link

4, react-native run-ios/run-android

I did not configure Automatic setup with Cocoapods In ios, it is recommended to update the document, to prevent the user with trouble.
@zoontek

@giantss What version of RN are you using?

@zoontek 0.49.5

@zoontek - with your change it's working. I guess we need a pull request :)

@compojoom feel free to do it :)

@zoontek - I see that we already have one
https://github.com/AlexanderZaytsev/react-native-i18n/pull/153

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ankita-p17 picture ankita-p17  路  6Comments

ansmonjol picture ansmonjol  路  6Comments

AhsanAk picture AhsanAk  路  3Comments

henrikra picture henrikra  路  4Comments

SvetoslavSlavov picture SvetoslavSlavov  路  4Comments