Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Can't find variable: Symbol #498

Closed
KakarN opened this issue Jun 8, 2018 · 22 comments
Closed

Can't find variable: Symbol #498

KakarN opened this issue Jun 8, 2018 · 22 comments

Comments

@KakarN
Copy link

KakarN commented Jun 8, 2018

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.

@mweststrate
Copy link
Member

Fixed in #499 and released as 5.2.2

@KakarN
Copy link
Author

KakarN commented Jun 9, 2018

@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.

@kennethnym
Copy link

kennethnym commented Jun 10, 2018

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.

@mweststrate
Copy link
Member

Should be fixed in 5.2.3

@sasurau4
Copy link

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

@mweststrate
Copy link
Member

mweststrate commented Jun 11, 2018 via email

@sasurau4
Copy link

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!

@juanamd
Copy link

juanamd commented Jun 14, 2018

@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+?

@mweststrate
Copy link
Member

mweststrate commented Jun 15, 2018 via email

@z0nekill
Copy link

z0nekill commented Jul 4, 2018

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 👎

@hvaoc
Copy link

hvaoc commented Jul 18, 2018

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

  1. npm / yarn install jsc-android -D as dev dependency

  2. 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
   ...
}

@tusharmutreja
Copy link

MOBX COMPATIBILITY WITH react-native@0.56 ==> mobx to 4.3.1 and mobx-react to 5.1.0 .

@tokinonagare
Copy link

@hvaoc Thanks too much : ) you save my life.

hypest added a commit to wordpress-mobile/gutenberg-mobile that referenced this issue Sep 23, 2018
Need to bump minimum Android SDK version to 21 too.

Apparently, that error message is caused because older JavascriptCore
doesn't support "Symbol".

More:
mobxjs/mobx-react#498 (comment)
@pstanton
Copy link

pstanton commented Oct 3, 2018

update to @tusharmutreja 's fine post:
"mobx": "^4.5.0",
"mobx-react": "^5.2.8",

works a treat.

@JeffGuKang
Copy link

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.

@zdh
Copy link

zdh commented Nov 16, 2018

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.

@shuiRong
Copy link

shuiRong commented Dec 15, 2018

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

@TyLy83
Copy link

TyLy83 commented Dec 17, 2018

Thank shuiRong,
Your solution work for me.

@sanguineman91
Copy link

差评

@lironhl
Copy link

lironhl commented Feb 3, 2019

@hvaoc is declaring minSdkVersion 21, in android/app/build.gradle really necessary?

heathkit added a commit to Team488/ScoutingApp that referenced this issue Mar 4, 2019
Needed to update the JavaScript Core to do this:
mobxjs/mobx-react#498
@igor90007
Copy link

"mobx": "4.9.2",
"mobx-react": "5.4.3",
"react-native": "0.58.6",
works good

@mobxjs mobxjs locked as off-topic and limited conversation to collaborators Mar 4, 2019
@mweststrate
Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests