-
-
Notifications
You must be signed in to change notification settings - Fork 350
Maximum call stack size exceeded error in lifecycle methods #579
Comments
@smikula does this problem occur when using Background: we changed the method patching mechanism in 5.3 to help people that accidentally write stuff like cc @xaviergonz |
I'll take a look this afternoon and try to fix it, it seems that class also does its own patching of methods its own way |
Yeah current solution might be too complicated, maybe we should go back to the old monkey-patching mechanism, as that will play nice with other libs, and have the |
but I think it won't play nice with the patching from observer? |
I think I found the problem, will create a PR later |
PR ready |
Should be fixed in 5.3.4 |
I tried 5.3.4 and it worked. However, I just tried out 5.3.5 and am hitting what appears to be this issue again, with a slightly different callstack:
|
that's weird, there's now a unit test which uses the BaseComponent in office-ui-fabric-react to make sure it doesn't happen. Could you share a component where it happens? |
I suggest we go back to classic patching, which is less obtrusive and where
the edge cases are easier to grasp?
Op wo 24 okt. 2018 06:51 schreef Javier Gonzalez <notifications@github.com>:
… that's weird, there's now a unit test which uses the BaseComponent in
office-ui-fabric-react to make sure it doesn't happen. Could you share a
component where it happens?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#579 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhC_Td0wjUUvWTz1HcPGN2RB7ojpyks5un_G2gaJpZM4XvYcz>
.
|
I'd like to give it one last try, because to use the old patching method with disposeOnUnmount would make disposeOnUnmount depend on the class being marked with observer to work (not to mention that I think the old patching mechanism invoked the mixins multiple times when it was using inheritance and both the base and the inherited class were marked as observer, but I'm not 100% sure) (also I'm extremely curious what is the missing case given that the unit tests now cover that very same base component as well as recursive calls) in the worst case recursive calls could be totally prevented like in the previous fix, but I'd rather avoid that @smikula could you provide a simple component that exhibits that behavior? |
that being said, I so wished react had global lifecycle hooks / events |
Okay, I dug into it a bit on my side. First off, the reason your locking logic doesn't catch it is that the recursion happens via Second, it turns out this is due to interacting with different code, in this case another decorator that also overrides
|
so you use it like
I guess? If you write it like
it works, but nevertheless I'll take a look, thanks! |
@mweststrate Got it, PR created |
Released as 5.3.6 |
@xaviergonz check #588 / https://reactjs.org/docs/hooks-intro.html ;-) |
@mweststrate nice, didn't know about those :D
basically that'd avoid all the silly patching of course one could argue that if instead of using a decorator we were using the in other words
|
hmm actually, why doesn't (@)observer work like this? |
I encountered this error when upgrading to v5.3.2. (It doesn't happen in 5.2.x.) The issue is that certain lifecycle methods end up recursing infinitely—the callstack ends up looking something like this:
It appears this happens when
@observer
patches a component's lifecycle methods and something else is patching those methods as well, such as another decorator or a base class. (For instance the BaseComponent in office-ui-fabric-react does this.) I haven't dug into the mobx-react code enough to grok exactly what the problem is, but I've seen multiple instances of mobx-react interacting badly with other libraries that do this sort of thing.The text was updated successfully, but these errors were encountered: