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

Svelte 5: $json returns undefined on initial load of the page #261

Open
TheRealSeber opened this issue Oct 22, 2024 · 0 comments
Open

Svelte 5: $json returns undefined on initial load of the page #261

TheRealSeber opened this issue Oct 22, 2024 · 0 comments

Comments

@TheRealSeber
Copy link

TheRealSeber commented Oct 22, 2024

Describe the bug

<script lang="ts">
	import { _, json } from 'svelte-i18n';

	interface Feature {
		title: string;
		iconName: string;
		description: string;
	}

	const features: Feature[] = $json('landingpage.features') as Feature[];
       console.log(features)
</script>

{#each features as feature}
	<div class="relative px-6">
		<h1
			class="flex flex-col items-center text-center text-xl font-semibold leading-7 text-neutral-700"
		>
			<Svg name={feature.iconName} />
			{feature.title}
		</h1>
		<dd class="m-2 text-center text-lg leading-7 text-neutral-600">
			{feature.description}
		</dd>
	</div>
{/each}

Logs
Simply features is undefined

Expected behavior
Don't return undefined. YES landingpage.features json exists and $_ works as expected in other elements

Information about your project:
Svelte 5
svelte-i18n 4.0.1
Additional context
Wrapping the features around new rune $state didn't work. Also after redefining locale, the features are displayed as expected.

@kaisermann seems to be pretty critical

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

1 participant