-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Reactive statements throwing TypeError from svelte plugin #2510
Comments
I'm guessing you're trying to set your page's title from within your component, whenever <script>
export let name;
$: if (name) {
document.title = name;
}
</script>
<h1>Hello {name}!</h1> If you just need to set it once in your component's load, then use <script>
import { onMount } from 'svelte';
export let name;
onMount(() => {
if (name) document.title = name;
});
</script>
<h1>Hello {name}!</h1> |
That worked! I literally just went off the API docs for this. Do the docs need updating? <script>
export let title;
// this will update `document.title` whenever
// the `title` prop changes
$: document.title = title;
$: {
console.log(`multiple statements can be combined`);
console.log(`the current title is ${title}`);
}
</script> |
Hmm, I think you caught a bug. This works: <script>
export let name;
$: {
document.title = name;
}
</script> This should work, but it's raising the error you mentioned: <script>
export let name;
$: document.title = name;
</script> Both are valid as per docs. |
handle unknown nodes in extract_identifiers
The previous statement does not work (see sveltejs#2510) I'm not able to fix it, so instead, let's just update the documentation :-)
The previous statement does not work (see sveltejs#2510) I'm not able to fix it, so instead, let's just update the documentation :-)
I just ran into an issue with Svelte with the reactive statements. I created a sample app using the
sveltejs/template
starter repo. I added a single reactive statement to theApp.svelte
component, which you can see hereHere is the error I'm getting:
Full repo here.
The text was updated successfully, but these errors were encountered: