ItalyPaleAle / svelte-spa-router

Router for SPAs using Svelte 3
MIT License
1.53k stars 105 forks source link

navigating within same component does not work #316

Closed b3b00 closed 6 months ago

b3b00 commented 7 months ago

Hello,

I have the followinng routes

  1. /Edit/:content : should open a component to edit some content
  2. /View/:content : should open a component to view some content

Routing works well except when I am trying to route from 1 /view/xxxx to another /view/yyyy : it stays on /view/xxx and does not update the content as expected. the same happens with /edit routes.

you can find an example here : https://svelte.dev/repl/8d695cd6a7de4e4f83a6968a8a22ef4a?version=4.2.9

you can see that the behavior is the same using either hash links or push calls.

We need to get out from a /view screen (going to /edit for instance) to be able to navigate to another /view instance.

could you help me debug this ? or is this simply impossible ?

Avalarion commented 7 months ago

Funny. I have exactly she same problem when finding an 5 hour old ticket about this^^

Avalarion commented 7 months ago

This worked for me: https://github.com/ItalyPaleAle/svelte-spa-router/issues/274#issuecomment-1253736873

ItalyPaleAle commented 7 months ago

The solution @Avalarion posted works.

Another solution is to change based on the prop reactively!

b3b00 commented 7 months ago

the solution from #274 is working well. I 've fixed my repl as an example : navigating within the same component

b3b00 commented 7 months ago

@ItalyPaleAle , could you elaborate on on your solution "change based on the prop reactively" ? I don't understand it , but I guess it does not need some wrapper component which will be better.