mobx: React Native + MobX: "RangeError: Maximum call stack size exceeded" when using @computed
I have a React Native project that uses MobX 5 (with the help of @babel/plugin-proposal-decorators and forced to the latest version of jsc-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.
// @flow import React, {Component} from 'react'; import {StyleSheet, View, Text} from 'react-native'; import {observable, computed} from 'mobx'; import {observer} from 'mobx-react'; type Props = {} export default @observer class App extends Component<Props> { @observable num = 0; constructor(props: Props) { super(props); setInterval(() => this.num++, 1000); } @computed get postfix() { return this.num === 1 ? 'second' : 'seconds'; } render() { return ( <View> <Text>{this.num} {this.postfix} have passed.</Text> </View> ); } }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?
react-native: 0.56.0 mobx: 5.1.0 mobx-react: 5.2.5 @babel/plugin-proposal-decorators: 7.0.0-beta.47 jsc-android: 224109.1.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (8 by maintainers)
@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
package.json
.babelrc
Still running into the same issue, Mobx version: 5.1.2
Code:
@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.