-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
Intended outcome:
Retrieve the object with all its properties when using the spread operator on a mobx observable
Actual outcome:
Retrieve the object without function properties when using the spread operator on a mobx observable
How to reproduce the issue:
export class TestStore {
constructor() {
makeObservable(this);
}
@observable
test?: object;
@action
setTest(test: object) {
this.test = test;
}
}
In my React Component
const myObject = {a: "a", b: "b", c: () => console.log("ok")};
console.log("simple var:", {...myObject});
testStore.setTest(myObject);
console.log("mobx observable:", {...testStore.test});
Console output:
simple var: {a: "a", b: "b", c: ƒ}
mobx observable: {a: "a", b: "b"}
Versions
Doesn't work on the last version:
"mobx": "^6.0.4",
"mobx-react-lite": "^3.1.6",
"mobx-utils": "^6.0.1",
Works on the previous version:
"mobx": "^5.15.4",
"mobx-react-lite": "^2.0.7",
"mobx-utils": "^5.6.1",
Thanks