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

ReferenceError: data is not defined #2943

Closed
pateketrueke opened this issue Jun 3, 2019 · 6 comments · Fixed by #8969
Closed

ReferenceError: data is not defined #2943

pateketrueke opened this issue Jun 3, 2019 · 6 comments · Fixed by #8969
Labels

Comments

@pateketrueke
Copy link

pateketrueke commented Jun 3, 2019

Using let:data from a custom component, and then using data inside a loop along with <select bind:value={anything}> tries to wipe-out data too!

See the example on the REPL: https://svelte.dev/repl/a05cc3a759f341479b56a944d60d4b20?version=3.4.4

Invalidation calls are:

$$invalidate('selected', selected);
$$invalidate('data', data); // `data` is not defined
@Conduitry
Copy link
Member

Is this the same as #2942 or is it a separate issue?

@pateketrueke
Copy link
Author

I think in my case data should not be touched, bindings are working fine but that additional invalidation makes no sense.

@zinthose
Copy link

zinthose commented Jun 3, 2019

In reference to #2942 , this may indeed be corollary issues. It appears as though some form of scope is locked into the included components.

@zinthose
Copy link

zinthose commented Jun 3, 2019

I see now, The issue is with the lack of binding the let: variable.
https://svelte.dev/repl/b4aaaf39a4cf4935a871c33feaa22f99?version=3.4.4

If you bind the let:variable to a locally defined variable there is no error.
In addition, if you don't supply a value to the "selected" variable it properly populates data at initialization. That might also be a bug. atm it's more of a "Gotcha" if the developer assumes the bound value is set from the child component.

@utherpally
Copy link

Any new on this?

@JoBurgard
Copy link
Contributor

I came across this in the current version. When this is resolved it would be possible to use components of a library in a more convenient way as you would not have to bind to a variable.

dummdidumm pushed a commit that referenced this issue Jul 19, 2023
Fixes #2943

The issue linked above invalidates a variable that is not defined in <script> but instead is defined as a let: variable, which does not make sense to invalidate, therefore, this PR exists.
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.

8 participants