-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Native + MobX: "RangeError: Maximum call stack size exceeded" when using @computed #1708
Comments
Also experiencing this issue |
Can someone set up a babel project that uses the same babel version as RN, for example based on https://github.com/mobxjs/mobx-react-boilerplate? Sounds as something that could relate to the beta version of babel used in RN 0.56 |
See also #546, issue seems to be related the latest RN version, and a solution can be found in the bottom of the thread. |
@mweststrate That issue does not seem at all related. Do you mean #1546? Either way, that is not the same problem. Even a simple computed property like below causes the same error. Verified with latest react-native 0.57.0 stable. @observer
export default class App extends Component {
@observable
a = 1;
@observable
b = 2;
@computed
get c() {
return this.a + this.b;
}
render() {
return (
<View>
<Text>
{this.a} plus {this.b} equals {this.c}
</Text>
</View>
);
}
} |
Sorry, linked to the wrong repo: mobxjs/mobx-react#546, there is a solution linked |
@mweststrate Do you mean this? oblador/react-native-vector-icons#801 (comment) I won't be able to try until monday, but I can't find any mention of |
Yes, afaik the problem is only introduced in RN 0.56 and never appeared
before, and that again is related to the babel version it ships with
Op vr 14 sep. 2018 om 16:01 schreef Jakob Ståhl <[email protected]>:
… @mweststrate <https://github.com/mweststrate> Do you mean this? oblador/react-native-vector-icons#801
(comment)
<oblador/react-native-vector-icons#801 (comment)>
I won't be able to try until monday, but I can't find any mention of
@computed. Is it @babel/plugin-transform-runtime that is supposed to
solve it?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1708 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhDuogSIAPfIrpeNdjqa5lIdJ_wlMks5ua7acgaJpZM4WUbho>
.
|
We've had no problems with 0.56. It wasn't until attempting an upgrade to 0.57 that the problem appeared. Of course it could be more about the specific babel plugins that we use rather than the RN version. |
@mweststrate I will try the linked solution ASAP - seems promising... |
@mweststrate I can't get the linked solution to work with RN 0.57 at all, despite a completely fresh project. The main difference being that the proposed solution uses an earlier RC of 0.57, which in turn uses babel 7 beta 47. Stable RN 57 uses stable babel 7, and no amount of tweaking the different versions of the packages got it working for me. index.js import applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
import { AppRegistry } from "react-native";
Object.assign(babelHelpers, {
applyDecoratedDescriptor,
initializerDefineProperty
});
AppRegistry.registerComponent("rn57", () => require("./App").default); package.json {
"name": "rn57",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"tsc": "tsc"
},
"dependencies": {
"@babel/plugin-proposal-decorators": "7.0.0",
"@babel/plugin-proposal-object-rest-spread": "7.0.0",
"@babel/plugin-transform-runtime": "7.0.0",
"@babel/runtime": "7.0.0",
"jsc-android": "^224109.1.0",
"mobx": "^5.1.1",
"mobx-react": "^5.2.8",
"react": "16.5.1",
"react-native": "0.57.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/react": "^16.4.14",
"@types/react-native": "^0.56.19",
"@types/react-test-renderer": "^16.0.2",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.45.3",
"react-test-renderer": "16.5.1",
"typescript": "^3.0.3"
},
"jest": {
"preset": "react-native"
}
} .babelrc {
"env": {
"development": {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-object-rest-spread",
[
"@babel/plugin-transform-runtime",
{
"helpers": true,
"regenerator": false
}
]
]
},
"production": {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]]
}
}
} |
I'm running into the same issue -- for me, this issue started happening only after upgrading from MobX 4.3.0 --> 5.1.2 I tried different combinations of intermediate versions and nothing worked so I fell back to MobX 4.3.0 I also noticed that only Dependencies
.babelrc
|
Note that `legacy: true` must still be set for plugin-proposal-decorators
Op wo 26 sep. 2018 om 00:54 schreef Mohamed Shibl <[email protected]
…:
I'm running into the same issue -- for me, this issue started happening
only after upgrading to MobX 5.1.2 from MobX 4.3.0
I tried different combinations of intermediate versions and nothing worked
so I fell back to MobX 4.3.0
I also noticed that only @computed values defined inside of a
React.Component instance seem to be causing the error -- otherwise works
fine on plain classes (ex. store)
*Dependencies*
"dependencies": {
"mobx": "^5.1.2",
"mobx-react": "^5.2.8",
"react": "16.5.0",
"react-native": "0.57.0"
},
"devDependencies": {
"metro-react-native-babel-preset": "^0.46.0",
***@***.***/core": "7.1.0",
***@***.***/plugin-proposal-decorators": "^7.1.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
***@***.***/runtime": "7.0.0",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.4.2",
"jest": "^23.5.0",
"jest-fetch-mock": "^1.6.5",
"jest-react-native": "^18.0.0",
"react-dom": "^16.4.2",
"react-test-renderer": "^16.4.2",
"schedule": "0.4.0",
}
*.babelrc*
{
"presets": ["module:metro-react-native-babel-preset"],
"env": {
"development": {
"plugins": [
***@***.***/plugin-transform-runtime"],
***@***.***/plugin-proposal-decorators", { "decoratorsBeforeExport": false }]
]
}
}
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1708 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhF6kj6TcffKerJYrw1wgne7GAufDks5uerQfgaJpZM4WUbho>
.
|
Still running into the same issue, Mobx version: 5.1.2
Code:
|
Closing, as to many individual reports are now mixed into one thread. Please note that the correct configuration for babel 7 is:
For any future reports of this issue, please open a new issue including reproduction |
See #1777 for details, but a fix has been released in 5.7.0 |
I have a React Native project that uses MobX 5 (with the help of
@babel/plugin-proposal-decorators
and forced to the latest version ofjsc-android
). I have a very simple app that worked just fine until I added a@computed
property. Here are the details:Provide error messages including stacktrace
Screenshot of red error screen: https://photos.app.goo.gl/aMNR7dAFtuUCehg97
Provide a minimal sample reproduction.
And follow the instructions here for configuring
jsc-android
.Elaborate on your issue. What behavior did you expect?
The exact same behavior as when omitting the
@computed
.Did you check this issue wasn't filed before?
Yes. I found some issues with a similar error, but the conditions were different (one issue was almost identical except it occurred on MobX 4, and resolved by updating to 4.1. I am using MobX 5.
State the versions of MobX and relevant libraries. Which browser / node / ... version?
The text was updated successfully, but these errors were encountered: