New Date().toLocaleString(); causes the Expo app to crash

Hi Guys,

if I try to run new Date().toLocaleString(); in Expo (I am using the newest SDK) the Expo app crashes.
Here is a Snack that shows the behaviour:
https://snack.expo.io/H154jws6Z

I’ve used this method before without any issues. Please tell me what I am doing wrong there :slight_smile:

1 Like

just tried on my latest version expo client app and it worked fine. On latest iOS

This is a known issue on Android with SDK 22. As a quick fix (depending on your use case) you can either do:

  1. Date.toLocaleString = Date.toString
  2. Implement Date.toLocaleString yourself by using a library like date-fns or moment.

We are tracking this issue upstream here: https://github.com/SoftwareMansion/jsc-android-buildscripts/issues/14 (please click Subscribe on that issue instead of commenting “+1” unless you have something helpful to contribute).

3 Likes