MobX 5.5 + React Native + @computed RangeError: Maximum call stack size exceeded
See original GitHub issueHi, I got react native and typescript running, updated the JSC (altered gradle build config) to the latest version to support MobX 5 (installed via npm). Everything works fine except for @computed
@observer
export default class App extends Component<Props> {
@observable public countVal:number = 0;
constructor(props, context){
super(props, context);
this.onPressLearnMore = this.onPressLearnMore.bind(this);
this.countVal = 0;
}
componentDidMount(){
console.log('started!');
}
onPressLearnMore(){
this.countVal = this.countVal + 1;
console.log(this.countVal);
}
@computed get twoX(){
return this.countVal * 2;
}
render() {
console.log('rendered!');
return (
<View style={styles3.container}>
<Text style={styles3.welcome}>Welcome to react!</Text>
<Text className={styles2.blue}>Welcome {this.countVal} & {this.twoX}</Text>
<Text style={styles3.instructions}>{instructions}</Text>
<Button
onPress={this.onPressLearnMore}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
</View>
);
}
}
This produces the error:
RangeError: Maximum call stack size exceeded
The stack trace is full of "get"calls in mobx.module.js:295:20 , so it means get is being run recursively.
- Downgrading to MobX v4.4 fixes the issue
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:35 (17 by maintainers)
Top Results From Across the Web
React, Uncaught RangeError: Maximum call stack size ...
I got 'Maximum call stack size exceeded', and similar errors because of framer-motion API dependency, version bigger than 4.1.17 (today's ...
Read more >Changelog - Cypress Documentation
Fixed a regression in 6.5.0 that could cause Cypress to crash with a RangeError: Maximum call stack size exceeded at _deconstructPacket error.
Read more >React integration - MobX
Using observables inside React components adds value as soon as they are either 1) deep, 2) have computed values or 3) are shared...
Read more >React Native + MobX: "RangeError: Maximum call stack size ...
React Native + MobX: "RangeError: Maximum call stack size exceeded" when using @computed.
Read more >mobx - npm
The observer wrapper around the TimerView React component will automatically detect that rendering depends on the timer.secondsPassed observable ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed and released as 5.7.0
Here is a minimal project reproducing the issue: https://github.com/Jakst/break-mobx5-computed-react-native https://expo.io/@jakst/expomobxcomputed