0
votes

I am working with svelte on a personal project (springboot + svelte + heroku). I have hardtime understanding why a component does not refresh when I am tryig to redisplay it :

here is a gist : https://svelte.dev/repl/a69ac7502677400081122453aa45dfbb?version=3.7.1

first app displays component First clicking [forward] display component Second. But then clicking [backward] does not bring back component First as I expect.

My general idea is using svelte to manage a tab oriented app : each tab is a component and sub-components. clicking on tab would display and hide tab components. even though it works great for the first tab changement next fails.

I 'm pretty sure it's possible to get such behavior, But I guess I must have misunderstood something...

Could someone epxlain me ?

Thanks

1

1 Answers

3
votes

In you second component you are dispatching gothird

function forw() {
    dispatch('gothird');
}

but you are still using the on:next prop when using the component

<Second on:back={ back } on:next={gothird}/>

You need to update one or the other so that you are using the event you are actually dispatching from your component.