Search code examples
react-native

Unexpected token '?' no stack in React Native


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

enter image description here


Solution

  • 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.)