React Native code doesn't work without Remote Debugger enabled

后端 未结 3 1016
面向向阳花
面向向阳花 2021-02-07 18:27

This a weird question, but since I\'m really curious about this I wanted to ask. I have a piece of code that works in the iOS Simulator when I enable Remote Debugging but it sto

3条回答
  •  梦谈多话
    2021-02-07 19:10

    I had the same problem at first, I thought there might be something wrong within the device. Further digging into it I found it had something to do with the new Date() library.

    I used below piece of code to solve the problem :

      convDate(dateStr) {
        // From mm-dd-yyyy to yyyy-mm-ddThh:MM:ssZ
        var dArr = dateStr.split("-");
        return dArr[2] + "-" + dArr[0] + "-" + dArr[1] + "T00:00:00"; //2017-09-13T00:13:28
      }  
    

    I called the method like this:

    const check = new Date(this.convDate(givenDate));
    

提交回复
热议问题