Open elron opened 1 year ago
Look like this is linked to this issue: https://github.com/sveltejs/svelte/issues/8213
There is a strange behavior with SSR and Browser update, hydration of {@html}
don't see to work (but later update are OK)
You can reproduce the error without my lib:
<script>
import { writable } from 'svelte/store';
// import { persist, createLocalStorage } from '@macfja/svelte-persistent-store';
import { onMount } from 'svelte';
import { browser } from '$app/environment';
const posts = [
{
id: 1,
content: '<span style="color:red;">Post One</span>'
},
{
id: 2,
content: '<span style="color:blue;">Post Two</span>'
}
];
const postId = writable(1); //persist(writable(1), createLocalStorage(), 'postId');
if (browser) $postId = 2
$: currentPost = posts.find((post) => post.id === $postId);
/*onMount(() => {
$postId = 2;
});*/
</script>
<h1>Post ID: {currentPost.id}</h1>
<h2>{@html currentPost.content}</h2>
When I use a writable with createLocalStorage and then update, it updates the variable everywhere, but ignores the variable when used with
@html
Please check out this repo (Check out +page.svelte): https://www.sveltelab.dev/tfpbg025yxmqvpd