Closed
Description
Describe the bug
store.js
import { writable } from 'svelte/store';
export const activeRoute = writable({});
Router.svelte
import { activeRoute } from './../store.js';
//some function here which is updated the store $activeRoute
<Route currentRoute={$activeRoute } />
Route.svelte
<script>
export let currentRoute = {};
</script>
{#if currentRoute.layout.viewed == false}
<svelte:component this={currentRoute.layout.layout} currentRoute={{ ...currentRoute, layout:{layout:currentRoute.layout.layout,viewed:true}}}/>
{:else if currentRoute.component.viewed == false}
<svelte:component this={currentRoute.component.component} currentRoute={{ ...currentRoute, component:{layout:currentRoute.component.component,viewed:true}}}/>
{/if}
in the browser mode single page application working fine as exptected
but when we try to run the same app which is build / compiled for ssr support its fail at
{#if currentRoute.layout.viewed == false}
for the solution for this i changed the code in Router.svelte
Router.svelte
import { activeRoute } from './../store.js';
//some function here which is updated the store $activeRoute
const unsubscribe = activeRoute.subscribe(value => {
currentRoute = value;
});
<Route currentRoute={currentRoute} />
and instead of $activeRoute now i am passing currentRoute
so i dont know its error or we cant not use direct $store into as prop but think to just report in case.
thanks
Metadata
Metadata
Assignees
Labels
No labels