preactjs / preact-router

:earth_americas: URL router for Preact.

Home Page:http://npm.im/preact-router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assets of component with path '/' are loaded on every route

rubenpoppe opened this issue · comments

I noticed that when built, my app loads images from Home (path="/") on every other route too.

<Router>
  <Home path="/" /> {/*thumb images should be loaded*/}
  <About path="/about" /> {/*images should not be loaded*/}
  <Article path="/:slug" /> {/*images should not be loaded*/}
</Router>
Home About Article
image image image

I guess in react-router it would be solved with adding exact to the first route, but I don't know of such behavior in preact-router.

It seems the contents of Home briefly flash on the screen so it would seem more like why Switch is implemented.

It comes down to pre-rendering. Adding the prerender-urls fixes it.