-
-
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
MobX 5.5 + React Native + @computed RangeError: Maximum call stack size exceeded #1777
Comments
There are several reports similar to this one, including solution, did you
check those?
Op za 13 okt. 2018 10:37 schreef xfactor5 <notifications@github.com>:
… 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.
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1777>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhAgoQGOtcuGSR5NHv7t3JWhTUrYrks5ukaYwgaJpZM4XahkD>
.
|
I checked all of them. I did not find any solution provided, only one by yourself if I am not mistaken that was about modifying babel.rc file which did not work and had no effect. |
Ok that sounds like RN issue then? If config is not respected not much we
can do.
Note that you can always work around not having decorator syntax using the
decorate utility.
Op za 13 okt. 2018 15:53 schreef xfactor5 <notifications@github.com>:
… I checked all of them. I did not find any solution provided, only one by
yourself if I am not mistaken that was about modifying babel.rc file which
did not work and had no effect.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1777 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhBFz6P0gAyg9MFoBDE3e7KRRMTxwks5ukfBSgaJpZM4XahkD>
.
|
I don't think so! RN works with 4.4 (with old or updated JSC) anyway, 5.5 with the newly updated JSC has issues and 5.5 does not work on the normal react native at all. And even if it's RN, I think if you create an issue for them it would be much more sensible to get this over with. We are talking about a very large audience base of MobX being left out in a major version upgrade ... I think we deserve more than a workaround, I believe v5.5 must be usable by everybody in the normal way so I would appreciate if you dig into this problem a little bit more. Right now, if someone runs npm install mobx + npm install mobx-react, version 5 will be installed and they will get errors that Proxy and Symbol are not supported. |
and by the way, the reason I fell for MobX was the decorator syntax and I am very uncomfortable ditching that! |
Note that mobx 4 is just as actively maintained! Every new feature was and
will be backported.
Op za 13 okt. 2018 18:15 schreef xfactor5 <notifications@github.com>:
… and by the way, the reason I fell for MobX was the decorator syntax and I
am very uncomfortable ditching that!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1777 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhOARN_NVceXVWwTJbFDN277zCHcrks5ukhGPgaJpZM4XahkD>
.
|
OK, then it's your call... but if you can find a fix it would be much better. |
@xfactor5 could you answer the following questios for some deeper investigation?
|
Sure...
|
I have almost same problem with RN0.56 |
Could someone provide the default babel configuration for RN 0.56 / 0.57?
Op do 18 okt. 2018 om 10:14 schreef Artur Eshenbrener <
notifications@github.com>:
… I have almost same problem with RN0.56
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1777 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhIWwq34_93b8lOpsyMAzucBMh7_2ks5umDhPgaJpZM4XahkD>
.
|
@mweststrate this is clean app for RN0.56: https://github.com/ncuillery/rn-diff/tree/rn-0.56.0/RnDiffApp You can check versions of babel, |
I tried reproducing the issue, but I am a total RN / android noob, and I have no clue what upgrading gradle files means :-). Could some setup an expo based project which I can just star, scan the code an be on my way? |
@xfactor5 also, for clarification "The problem only happens when @computed is added" with added, you mean to a react component, correct? |
In the mean time, updated the Readme to reflect that for now probably it is the most convenient to just stick to MobX 4 for React Native Android. I doubt upgrading JSC core, for the sole purpose of being able to use MobX 5, is justifiable at this point. |
React component is for sure but I have not tested on others. Last time I upgraded to MobX 5 to test for you, I encountered a react native bug and got stuck for 2 hours so, to be honest, I am not gonna test that again :D If I get time I will check it and report back. |
N.B.: This solution is known to work for some at least, so just linking it here again for any future readers :). oblador/react-native-vector-icons#801 (comment) |
Another observation: seems at least 25 people were able to get MobX 5 + RN Android working properly if I read these results correctly. Curious where the differences are. Minimal reproduction would be greatly appreciated. https://twitter.com/mweststrate/status/1053265411834372096 |
I don't know maybe they did not use computed ... or maybe some different config or plugin set in babel or even maybe no typescript? |
I also encountered this and workarounds don't work. Are there any plans on having this resolved on mobx side? |
did not read how other people fixed it, but I fixed this issue by removing circular dependencies. tip: use |
this solution worked on 3/4 differents packages showing the problem. |
@rvion But how exactly it work? |
Don't know, I didn't spend time trying to understand. I guess it depends what your transpiler / runtime module system is. On a project with typescript (w/ decorator + decorator metadata) and |
Closing for now, clearly, it is not solved for everyone, but it isn't failing for everyone either. So there are external factors in play. However, without a reproducible setup this can't be investigated. Please refrain from commenting with additional examples of this problem without reproducible setup. |
Running into this issue for react-native@0.57.5 using mobx@5.6.0 & mobx-state-tree@3.8.1. If I use a computed value on my decorated class I get the following error: RangeError: Maximum call stack size exceeded. Everything else is working fine. It's a shame that we can't utilise the computed feature for React Native! @mweststrate to reproduce - create a fresh react native app:
|
I found out, that this problem exists only when using @computed inside the react class component. |
Curious, is it related to hot reloading? Can that turned of manually in RN?
Op ma 3 dec. 2018 om 08:09 schreef Eugene Alitz <notifications@github.com>:
… I found out, that this problem exists only when using @computed inside the
react class component.
If i use this in the Store - everything works just fine
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1777 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhBW8VLKGAQBolOgLLkDZ_fiUoAvmks5u1M4jgaJpZM4XahkD>
.
|
Yes, this can be achieved through dev -menu, but it doesnt help |
Here is a minimal project reproducing the issue: |
Thanks for the repo @jakst! |
Fixed and released as 5.7.0 |
@mweststrate there's a little blurb in the README that refers to this issue:
Is the part "decorators can be troublesome" still applicable? (It refers to this issue.) |
Nope, that was fixed!
Op ma 4 feb. 2019 18:16 schreef Dakota St. Laurent <notifications@github.com
…:
@mweststrate <https://github.com/mweststrate> there's a little blurb in
the README that refers to this issue:
MobX >=5 runs on any browser with ES6 proxy support. It will throw an
error on startup on older environments such as IE11, Node.js <6 or React
Native Android on old JavaScriptCore how-to-upgrade. Warning: since
upgrading JSC is non-trivial, and decorators can be troublesome as well in
React Native, for now it is recommended to stick to MobX 4.x for for React
Native Android development.
Is the part "decorators can be troublesome" still applicable? (It refers
to this issue.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1777 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhOXHNmCUXTt-xJsHewd1AF44HhnIks5vKGrzgaJpZM4XahkD>
.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions. |
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
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.
Thanks
The text was updated successfully, but these errors were encountered: