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

Store object binding on component #7106

Closed
SiaEmgee opened this issue Jan 6, 2022 · 6 comments
Closed

Store object binding on component #7106

SiaEmgee opened this issue Jan 6, 2022 · 6 comments

Comments

@SiaEmgee
Copy link

SiaEmgee commented Jan 6, 2022

Describe the bug

Binding nested object of a store -on component- causes an extra reactivity call (at initialization once)

Ver: 3.44.3

Reproduction

https://svelte.dev/repl/3aa2f6b4f5c844748c34cca5ea8d4b02

Logs

No response

System Info

Microsoft Edge
Version 89.0.774.63 (Official build) (64-bit)

Severity

blocking all usage of svelte

@Prinzhorn
Copy link
Contributor

This looks like a duplicate of #6298 or #5689 ?

@SiaEmgee
Copy link
Author

SiaEmgee commented Jan 6, 2022

This looks like a duplicate of #6298 or #5689 ?

I'm sorry I don't get the problem in your example. it logs once

@Prinzhorn
Copy link
Contributor

I'm sorry I don't get the problem in your example. it logs once

It shouldn't log anything. There is absolutely no reason for Svelte to call store.set just by rendering stuff. Why would you expect that to happen?

@SiaEmgee
Copy link
Author

SiaEmgee commented Jan 6, 2022

I'm sorry I don't get the problem in your example. it logs once

It shouldn't log anything. There is absolutely no reason for Svelte to call store.set just by rendering stuff. Why would you expect that to happen?

Aren't you assigning this : {id: 1, name: 'tab1'} , and you are right I changed it to [{id: 1, name: 'tab1'},{id: 2, name: 'tab2'},{id: 3, name: 'tab3'}] and it logs three times in a loop and it means the cause of triggering is "binding" not assignment

@Prinzhorn
Copy link
Contributor

and it logs three times in a loop and it means the cause of triggering is "binding" not assignment

Yes, part of the confusion is that I edited the REPL instead of forking it. The original REPL was using {#each} and there was a set call for every iteration. But I changed it here #6298 (comment) because it turns out that the underlying issue is bind itself, it just happens for every iteration.

To be clear: bind should not by itself cause set, this is what we are both seeing, hence I think these are all the same issue. You are seeing the same value twice because subscribe is trigger by the unnecessary set.

@SiaEmgee
Copy link
Author

Dup : #6298

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