Skip to content
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

Using spread operator on observable object remove some properties (function) #2637

Closed
pinonpierre opened this issue Nov 23, 2020 · 3 comments

Comments

@pinonpierre
Copy link

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

@danielkcz
Copy link
Contributor

danielkcz commented Nov 23, 2020

Please provide runnable reproduction.

@pinonpierre
Copy link
Author

pinonpierre commented Nov 23, 2020

@urugator
Copy link
Collaborator

Duplicate of #2629 and #2586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants