Can't find variable: Symbol
KakarN opened this issue · comments
I am trying to integrate mobx/mobx-react into my react-native project. But I was stuck when I tried to import Provider into the main App.js.
I have this error:
Error: "Can't find variable: Symbol Evaluating module://mobx-react.js Evaluating module://App.js Loading module://App.js" in
On further checking I found that the latest version of the mobx/mobx-react was the problem. When I installed the old version, the error was gone.
You can check the latest mobx/mobx-react version snack here, which does not work.
And the old version of mobx/mobx-react version of snack here, which does work.
Fixed in #499 and released as 5.2.2
@mweststrate I am sorry, but I think it's not fixed yet. I have tried with the updated release version ("5.2.2"), but I am still getting the same error:
Error: "Can't find variable: Symbol Evaluating module://mobx.js Evaluating module://mobx-react.js Evaluating module://App.js Loading module://App.js" in
You can check the updated release version's snack here.
Same issue here with react-native@0.55.4
with mobx@5.0.0
and mobx-react@5.2.2
. Downgrading mobx to 4.3.1
and mobx-react to 5.1.0
fixed the issue for me.
Should be fixed in 5.2.3
Thank you for fixing!
But same issue here with react-native@0.54.4
, mobx@5.0.0
and mobx-react@5.2.3
on Android emulator.
Turning on Debug JS Remotely
fixed the issue for me.
snack here
Oh I didn't know The default JavaScriptCore on Android is so old!!!
Think about upgrading jscore or using MobX v4 instead of v5.
Thanks!
@mweststrate What you mention is really interesting; didn't know about RN and jsc.
I've tried your solution though, but it mentions that it requires a min sdk version of 21 for it to work. Is there any workaround to keep min version 16 while also being able to upgrade to mobx to v5.0+?
Just followed the instructions that @mweststrate put together.. worked a treat!
cheers mate!
mobx: ^5.0.3
mobx-react: ^5.2.3
react-native: 0.55.4
Heads up as others are saying - the change requires setting the minimum android SDK version to 21. Otherwise you're looking at downgrading 👎
Version Info:
"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"react": "16.4.1",
"react-native": "^0.56.0"
Followed these steps based on @mweststrate 's response to fix this
Source: https://github.com/react-community/jsc-android-buildscripts#how-to-use-it-with-my-react-native-app
-
npm / yarn install jsc-android -D
as dev dependency -
Make changes to android gradle files
android/build.gradle
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// ADDED THIS - Local Maven repo containing AARs with JSC library built for Android
url "$rootDir/../node_modules/jsc-android/dist"
}
}
}
android/app/build.gradle
android {
...
defaultConfig {
minSdkVersion 21
}
...
}
configurations.all {
resolutionStrategy {
force 'org.webkit:android-jsc:r224109'
}
}
dependencies {
...
compile 'org.webkit:android-jsc:r174650' // ADDED THIS
...
}
MOBX COMPATIBILITY WITH react-native@0.56 ==> mobx to 4.3.1 and mobx-react to 5.1.0 .
update to @tusharmutreja 's fine post:
"mobx": "^4.5.0",
"mobx-react": "^5.2.8",
works a treat.
update to @tusharmutreja 's fine post:
"mobx": "^4.5.0",
"mobx-react": "^5.2.8",works a treat.
It works well on React-Native 0.57.
Same issue here with react-native@0.57.5 with mobx@5.6.0 and mobx-react@5.3.6.
Downgrading mobx to 4.3.1 or upgrade your JavaScriptCore.
That all works well on React-Native 0.57.5.
It's my setting: (works for me)
devDependencies
...
"@babel/plugin-proposal-decorators": "^7.2.2",
"metro-react-native-babel-preset": "0.50.0",
"babel-preset-mobx": "^2.0.0",
"jsc-android": "^236355.1.1",
"mobx": "^5.8.0",
"mobx-react": "^5.4.3",
...
.babelrc
{
"presets": ["module:metro-react-native-babel-preset","mobx"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }]
]
}
and upgrade JavaScript Core
Thank shuiRong,
Your solution work for me.
差评
@hvaoc is declaring minSdkVersion 21, in android/app/build.gradle really necessary?
"mobx": "4.9.2",
"mobx-react": "5.4.3",
"react-native": "0.58.6",
works good
Locking conversation, too many random comments that don't add anything to the conversation. Please open a new issue if still running into trouble not solved by what has been mentioned before already