question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MobX 5.5 + React Native + @computed RangeError: Maximum call stack size exceeded

See original GitHub issue

Hi, 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:35 (17 by maintainers)

github_iconTop GitHub Comments

7reactions
mweststratecommented, Dec 3, 2018

Fixed and released as 5.7.0

2reactions
jakstcommented, Dec 3, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found