skip to Main Content

I’m getting unexpected token '?' error. But, on debug mode, the error disappears.

enter image description here

2

Answers


  1. In my case, this issue happened to me after I installed an example app with:

    "metro-config": "^0.72.1" and "react-native": "0.70.0-rc.4".

    While my main app was still using "react-native": "0.66.4"

    It also replicated when I reverted the code. So I came up with this solution:

    1. Delete that example app
    2. Reset
    3. do the yarn cache clean and npm cache clean -f

    And the problem disappears.

    Login or Signup to reply.
  2. I was having this exact problem, but only in Android. The problem was caused by my use of a nullish coalescing assignment operator (??=). For example, something like:

    obj ??= {};
    

    React Native doesn’t support this operator. Therefore, look for all occurrences of ??= in your code and try changing it to the extended way; e.g.:

    if(obj == undefined)
       obj = {};
    

    You must avoid using this operator until React Native adds support for it.

    (I’m not sure, but the nullish coalescing operator (??) may lead to the same problem, so you may wish to avoid it, too.)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search