This repository has been archived by the owner on Dec 31, 2020. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Schedule uncommitted reaction cleanup #121
Schedule uncommitted reaction cleanup #121
Changes from all commits
44ee8c2
67d08c6
e055f95
9c06f46
bbfe305
f59a01d
466fbfc
7eb47d3
502bb68
c4c6bc6
6c78e5b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this disposal removed? If a component throws we can safely dispose (and also clean up the global state) since this very same instance is never going to come back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding this, out of blue, I run into the issue when a reaction is disposed here and then component re-renders and the
track
fails to get executed on disposed reaction. I am not sure how is it possible, I tried to figure out some contained repro, but no luck. I suppose for the sake of such errors, the ref value should be unset here as well.Note: I am using the latest
mobx-react-lite
, none of these experiments nor #119There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the component is going to be unmounted because of the error situation, it'll go through the cleanup logic in
useEffect
, which will already cause the reaction to be disposed. (Or, if it's throwing on first render, the cleanup work is already scheduled.)I was attempting to reduce duplicated code as this particular
.dispose()
call is no longer needed.