3

I'm creating an React-Native App, which is working fine on the emulator on DEBUG mode. However, when I tried on on RELEASE mode, it crashes because of a failing module.

The ADB Logcat points to this message as a cause of the exception:

 ReactNativeJS: Requiring unknown module "./locale/pt-br".

I know it's being caused by a call to method "updateLocale" of momentJS library. This call is placed inside the "react-native-calendar-strip" component, when I need to set a different locale options.

I've tried a lot of different combinations on import statements, none of them working.

This is what I tried:

import moment from 'moment';
import 'moment/locale/pt-br';

or

import moment from 'moment/min/moment-with-locales';

I also tried to require the locale

require('moment/locale/pt-br'); 

Any other suggestion ?

Fernando Vieira
  • 3,177
  • 29
  • 26

1 Answers1

6

I just figured out the solution:

I organized my imports like this:

import 'moment';
import 'moment/locale/pt-br';
import moment from 'moment-timezone';

Then, on the beginning of the code, I had set the locale manually, before the react-native-calendar-strip could call the updateLocale method, like this:

moment().locale('pt-br');

To make sure everything works fine, I left the momentjs dependency on the same version as of the react-native-calendar-strip, which was

"moment": "^2.17.1",
Fernando Vieira
  • 3,177
  • 29
  • 26