All Questions
Tagged with svelte-5 javascript
20 questions
0
votes
0
answers
38
views
Returning an array from server-side to client-side in Svelte 5
I am using Svelte5. When I send an array from +page.server.js to +page.svelte it always works server-side and the array is sent as expected. However when +page.svelte is running on the client side ...
1
vote
0
answers
79
views
Svelte 5 memory leak in simple example
I'm encountering many memory leaks when using both Svelte 4 and 5 on reasonably complex projects, and having trouble identifying what I'm doing wrong.
Here is an extremely simplified Svelte 5 example (...
0
votes
2
answers
77
views
Svelte 5 Unsafe State Mutation at Tree Component
I need help with Svelte components. I've built a tree that should allow users to check nodes and update related nodes. When a node is checked, its parents and children should react accordingly. ...
0
votes
1
answer
64
views
How to get a component's children height?
I'm trying to create a component that will render it's children when it comes into the viewport, here's the code:
<script lang="ts">
import type { Snippet } from 'svelte';
...
0
votes
1
answer
53
views
How to dispatch multiple events from a component?
Let's imagine we have simple <input> with onChange and onPaste event. In Svelte4 I have used to use this code:
import {createEventDispatcher} from "svelte";
const dispatch = ...
1
vote
0
answers
49
views
svelte 5 not updating during outro
I am in the middle of a migration from svelte 4 to svelte 5 and I've run into an issue.
Previously when there was an update to a variable the component updated in response to it, even if the component ...
1
vote
2
answers
505
views
Other than children(), can I import and render multiple snippets in +layout.svelte that are defined in +page.svelte?
New to SvelteKit and trying to figure this part out...
Here's a couple of ways I was trying to achieve this, but the sidebar either doesn't load, or the navigation appears twice for some reason; with ...
0
votes
1
answer
58
views
How to fix non-reactive nested objects inside a $state([]) in Svelte?
Here's the link to repro (Svelte Playground).
The problem is that when you add a "waypoint" and toggle the checkbox to enable its bearings (thus changing the respective nested object's ...
0
votes
1
answer
64
views
Effects no longer work with reactive objects when using runes
In Svelte 4, the effect below would fire every time user or pass props from it changed
let data = {
user,
pass,
};
$: data && clearErrors()
In Svelte 5 the equivalent code with runes ...
1
vote
1
answer
294
views
$state object could not be cloned
After I switched to Svelte 5 syntax I am getting this error when I pass a reactive variable to a function
let details = $state({
user: '',
pass: ''
})
// ...
await login(details) // <- error
...
2
votes
1
answer
181
views
Svelte 5: Form briefly appears then disappears on page load when using conditional rendering for an image
I'm encountering a strange issue with a Svelte 5 component where a form briefly flashes on the screen for about half a second when the page loads, and then disappears. This happens when I have ...
0
votes
1
answer
116
views
Loading data server side and allow global access client side
I'm having a hard time understanding the use of Runes and data loading.
I load a supabase json file and I want to access the data globally.
// +page.server.js
export async function load() {
const [...
0
votes
1
answer
71
views
Svelte:window component onload not triggering
In Svelte5, why is the onload event not triggering the function foo() in src/routers/+layout.svelte?
<script>
const foo = () => console.log('foo triggered')
</script>
<svelte:...
0
votes
1
answer
63
views
How to pass value to rendered children?
I have an await block in my +layout.svelte for a product fetch function in the load function.
When the promise is fullfilled it renders a +page.svelte as a children and I need to pass the product to ...
0
votes
1
answer
149
views
Embedding Svelte 5 inside PHP (Imperative component API)
I'm trying to use Svelte 5 and SvelteKit inside PHP.
I don't understand how to use the Imperative component API (https://svelte.dev/docs/svelte/imperative-component-api). Where do I put the following ...