web-ridge / react-native-paper-dates

Smooth and fast cross platform Material Design date and time picker for React Native Paper
https://www.reactnativepaperdates.com
MIT License
663 stars 170 forks source link

Android gives error "ReferenceError: Can't find variable: Intl" #213

Closed MehmetKaplan closed 1 year ago

MehmetKaplan commented 1 year ago

First, an atomic example can be found in this snack:

https://snack.expo.dev/@mehmetkaplan/issue-react-native-paper-dates-android-intl

When I do the same in local machine, the error is:

ERROR  ReferenceError: Can't find variable: Intl

This error is located at:
    in HeaderContentSingle (created by DatePickerModalContentHeader)
    in RCTView (created by View)
    in View (created by DatePickerModalContentHeader)
    in RCTView (created by View)
    in View (created by DatePickerModalContentHeader)
    in RCTView (created by View)
    in View (created by DatePickerModalContentHeader)
    in DatePickerModalContentHeader (created by DatePickerModalContent)
    in RCTView (created by View)
    in View (created by DatePickerModalHeaderBackground)
    in RCTView (created by View)
    in View (created by AnimatedComponent)
    in AnimatedComponent
    in AnimatedComponentWrapper (created by DatePickerModalHeaderBackground)
    in DatePickerModalHeaderBackground (created by DatePickerModalContent)
    in DatePickerModalContent (created by DatePickerModal)
    in RCTView (created by View)
    in View (created by DatePickerModal)
    in RCTView (created by View)
    in View (created by DatePickerModal)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer (created by Modal)
    in RCTView (created by View)
    in View (created by Modal)
    in VirtualizedListContextResetter (created by Modal)
    in RCTModalHostView (created by Modal)
    in Modal (created by DatePickerModal)
    in RCTView (created by View)
    in View (created by DatePickerModal)
    in DatePickerModal (created by DatePicker)
    in DatePicker (created by UpdateUserView)
    in RCTView (created by View)
    in View (created by GridBox)
...

The snack has the error:

image

Can be related with https://github.com/web-ridge/react-native-paper-dates/issues/37, but I think they are different.

RichardLindhout commented 1 year ago

It's because hermes is not enabled

MehmetKaplan commented 1 year ago

Thanks a lot.

I am giving my question a "thumb down" since I became the guy who did not RTFM. :-)

For the other lazy folks, my case was for Expo SDK 47, where Hermes was not enabled by default for Android. After adding the expo.jsEngine parameter in the app.json, everything was OK:

...
"jsEngine": "hermes",
...

PS: Android (emulator), ios (simulator) and web (chrome), all are confirmed. Android and iOS use the Hermes but the web does not.

RichardLindhout commented 1 year ago

It's faster too :-). And indeed on the web it uses the browser Intl api's which are a big selling point as they don't add to the bundle sizes anymore with unlimited locale's. Hermes also uses native iOS/Android date api's to implement Intl which is really great, and the bundle sizes won't grow much when you add more languages