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

Merge props function mutates given object. #10

Closed
Aaron-Pool opened this issue Aug 16, 2018 · 1 comment
Closed

Merge props function mutates given object. #10

Aaron-Pool opened this issue Aug 16, 2018 · 1 comment

Comments

@Aaron-Pool
Copy link

Aaron-Pool commented Aug 16, 2018

I suppose this could be intended behavior, but if it is, I think it shouldn't be.

I was writing some stories for my vue storybook and ran into an instance where I was iterating over different variations of a component like so:

render() {
    types = [...blah];
    types.map(t => {
        const data = { attrs: { types[t]: true } };
        <ProfilePic {...data} />
        <ProfilePic url={picUrl} {...data} />
    }
}

I was getting odd behavior on the second component, and I managed to track it down to the fact that the data object is actually mutated in the creation of the first element. All the props are removed from the data object when props are "extracted" and applied to the element.

Is this intended behavior? or a bug? It seems like the data object to be merged should be cloned instead of mutated, but let me know if there's a reason for this. I can create a repro code pen if needed.

@yyx990803
Copy link
Member

I don't think the issue is from this package. The implementation does not perform any mutations here.

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

No branches or pull requests

2 participants