-
-
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
Cycle detected on latest version of mobx #540
Comments
Full stacktrace might be a good place to start. Best to set the max reported stacklines to infinite, and limit the stack depth, to keep it readable :). Or manually bail out in |
Reproducable use case: var mobx = require("mobx");
var objWrapper = mobx.observable({
value: null,
});
var obj = {
name: "Hello",
};
objWrapper.value = obj;
mobx.extendObservable(objWrapper, obj);
mobx.autorun(() => {
console.log(objWrapper.name);
}); MobX 2.4.4 runs fine |
Oh and to add to the above. Is it something inherently wrong with doing what I do here? Extending an observable with another observable? And I see no cycles here. |
@nsf that depends on which behavior you expect. |
But why does it reports cycles in this case then? is it fair to say that |
@nsf yes. the cycle is probably a bug, will investigate. Is the cycle still reported if actually using the |
@mweststrate runs fine with toJS. |
@nsf / @ochervak proposal (see PR) is to fix this by explicitly forbidding this. Would this pose any problems for you? |
I'm okay with that. It also gives an explicit hint that properties are not somehow magically reused, but a completely different observable object is created instead. Also btw, I don't know if my issue matches originally reported issue here. So, can't speak for @ochervak. Not even sure if this fix fixes his problem. But it's a newly introduced cycle detection that wasn't here before that. |
Fixed #540 by explicitly forbidding extending with observable objects
After updating to MobX 2.5.1 i encountered a problem with
How can i fix it? It not reproduces on previous versions...
The text was updated successfully, but these errors were encountered: