-
-
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
trace(): log when computed becomes suspended #2998
Conversation
🦋 Changeset detectedLatest commit: 9eca68b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
--- | ||
|
||
`trace()`: log when computed becomes suspended | ||
`requiresObserver` warns instead of throwing |
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.
I didn't see this change in the PR?
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.
typo ... requiresReaction
... the condition with die is deleted and merged to condition with warn:
warnAboutUntrackedRead_() {
if (!__DEV__) return
--- if (this.requiresReaction_ === true) {
--- die(`[mobx] Computed value ${this.name_} is read outside a reactive context`)
--- }
if (this.isTracing_ !== TraceMode.NONE) {
console.log(
`[mobx.trace] '${this.name_}' is being read outside a reactive context. Doing a full recompute`
`[mobx.trace] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`
)
}
--- if (globalState.computedRequiresReaction) {
+++ if (globalState.computedRequiresReaction || this.requiresReaction_) {
console.warn(
--- `[mobx] Computed value ${this.name_} is being read outside a reactive context. Doing a full recompute`
+++ `[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`
)
}
}
Looking good, thanks! |
Wasted a lot of time figuring out why tracing isn't working just to find out there was missing log when computed becomes suspended (mobxjs/mobx#2998, fixed in 6.3.3).
Wasted a lot of time figuring out why tracing isn't working just to find out there was missing log when computed becomes suspended (mobxjs/mobx#2998, fixed in 6.3.3).
trace
logs when computed becomes suspended as discussed in:#2859 (comment)
requiresObserver
no longer throws, but warns, so it's consistent withcomputedRequiresReaction
,observableRequiresReaction
, etcImproved console messages.