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

Spread Props in Component removes Reactivity #3521

Closed
dbowmanDT opened this issue Sep 6, 2019 · 6 comments · Fixed by #4487
Closed

Spread Props in Component removes Reactivity #3521

dbowmanDT opened this issue Sep 6, 2019 · 6 comments · Fixed by #4487
Labels

Comments

@dbowmanDT
Copy link

dbowmanDT commented Sep 6, 2019

Describe the bug
Using the spread operator in a #each loop in variable deconstruction and use the spread props feature along side other explicit props, makes the explicit props not reactive.

Logs
See REPL

To Reproduce
https://svelte.dev/repl/3c742a2e9ab145139a64a8c344982a3e?version=3.9.2

There is a comment in the FieldSet.svelte component indicating how to remove the {...props} from being adding props to the component. Removing that will make reactivity work again.

To see it work properly, you can set this to version 3.6.7

Expected behavior
I expected to be able to use spread props along side explicit props and that everything is reactive. Note I was not able to reproduce unless the prop being spread was inside a #each and deconstructed.

Information about your Svelte project:
See REPL

Severity
This is very specific and important to the project I am working on because the spread operator is allows me to only set the variables that I want to override the defaults for. If I have to explicitly set each prop then I will end up overriding defaults that I do not want to.

@Rich-Harris Rich-Harris added the bug label Sep 7, 2019
@markjaquith
Copy link

This also prevents the index from updating.

https://svelte.dev/repl/3d1764569a2b480ca752b7a86c5f992a?version=3.12.1

@arggh
Copy link
Contributor

arggh commented Nov 24, 2019

Update: bug still exists with 3.15.0

<!-- will not re-render when $activeItems changes -->
<MyComp {...data} isActive={$activeItems.has(id)}/>

New repro using the latest Svelte.

https://svelte.dev/repl/53a3e235612d4daebbd3df318afe187d?version=3.15.0

@dbowmanDT
Copy link
Author

@arggh Very nice. I too was going to check to see if this was incidentally fixed.

@jesper-bylund
Copy link

Is this still an issue? Seem to be having the same problem.

@pushkine
Copy link
Contributor

pushkine commented Jan 11, 2020

replace <Item {...item} ></Item>
with <svelte:component this={(v)=>{Object.assign(v.props,item); return new Item(v)}}/>
looks like that side steps the problem
it might introduce other bugs
https://svelte.dev/repl/1da799b8838d445ca5a95019823ca220?version=3.15.0

@ddnn55
Copy link

ddnn55 commented Feb 27, 2020

I am seeing a similar issue, but only when I specify a key expression in the #each. Is this the same issue, or different? See here: https://svelte.dev/repl/f68a4c8fe9e546bb9f577922415e6968?version=3.19.1

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

Successfully merging a pull request may close this issue.

7 participants