ItalyPaleAle / svelte-spa-router

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

is there a way to prevent nested router re-rendering the whole page everytime #285

Open putrasurya opened 1 year ago

putrasurya commented 1 year ago

I realized when having 3-level nested routes, every time the URL changes the whole page gets re-render every time. is it expected? or am I missing some configuration?

thank you

ItalyPaleAle commented 1 year ago

If the URL change impacts the outmost router, yes this is how it's supposed to work.

Do you need 3 nested routers? Or are you able to "flatten" it? Although nested routers are supported, I would consider them as "backup" option and would recommend flattening whenever possible.

putrasurya commented 1 year ago

yes, we sometimes need 3 nested routers or more when building not really a complex web app to memorize a page state by URL

a simple case looks like this one

/dashboard/ /dashboard/email /dashboard/email/read/id

when you are at page /dashboard/email and assuming you have 2 panes, the left pane is a list of emails and the right pane is for email content, and here you are already at level 2 of nested routers

when reading emails it feels odd when the browser re-rendered every time I go through emails, here you are at 3 levels of nested routers (/dashboard/email/read/id). the browser flashed a white screen for a very short moment