I’m getting unexpected token '?' error. But, on debug mode, the error disappears.
unexpected token '?'
2
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".
"metro-config": "^0.72.1"
"react-native": "0.70.0-rc.4"
While my main app was still using "react-native": "0.66.4"
"react-native": "0.66.4"
It also replicated when I reverted the code. So I came up with this solution:
yarn cache clean
npm cache clean -f
And the problem disappears.
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.)
??
Click here to cancel reply.
2
Answers
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:
yarn cache clean
andnpm cache clean -f
And the problem disappears.
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: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.: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.)