Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Dispose reaction on error inside rendering #134

Closed
wants to merge 4 commits into from
Closed

Dispose reaction on error inside rendering #134

wants to merge 4 commits into from

Conversation

andykog
Copy link
Member

@andykog andykog commented Oct 14, 2016

@mweststrate, sometimes in complex apps, when error happens inside rendering, we can't see original error, because of additional forceUpdate.
I've spent an hour trying to isolate this user-case: https://jsfiddle.net/Sl1v3r/1adco8hx/
May be you have a better idea on how to fix this?

@andykog andykog added the bug label Oct 14, 2016
@mweststrate
Copy link
Member

Updated the fiddle with a build based on this PR: https://jsfiddle.net/1adco8hx/4/

Can you elaborate why this PR makes a difference? Is that because how React handles errors internally? If that is the case I think this approach is fine.

Maybe a safety check if dispose isn't undefined, although I think theoretically that cannot be the case.

@andykog
Copy link
Member Author

andykog commented Oct 18, 2016

@mweststrate, I'm not completely sure, but I think, the problem is that when exception occurs inside render, react have no problem with handling it, but if there is synchronous forceUpdate after that, react throws it's own exception in some cases (Cannot read property 'getHostNode' of null). I can try to investigate, maybe that can & should be fixed inside React.

@mweststrate
Copy link
Member

@andykog would you be able to add tests that make the difference clear? I think this is a good addition, but might be nice to see the exact difference

@andykog
Copy link
Member Author

andykog commented Nov 7, 2016

@mweststrate, I've found that there is definitely nothing wrong with mobx-react, sometimes react just throws own exception when you call forceUpdate on component that met error during rendering. Here is an example without mobx: https://jsfiddle.net/Sl1v3r/70rd04yp/

So I've simply checked that components stop updating after error: 48319cc

(Maybe I'l make an issue/pr in react, if I'll manage to understand the root cause.)

@mweststrate
Copy link
Member

Merged into v4 branch

@mweststrate mweststrate closed this Nov 8, 2016
@github-actions github-actions bot mentioned this pull request Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants