-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oncreate always fired #1
Comments
Hi @rob-balfre! Thanks! Ouch. I'm not entirely sure how to mitigate this and still have SSR work, but I will look into it. |
Thanks for bringing this to my attention @rob-balfre. It turns out that this is the expected behavior of I think it would be best to add a warning to the documentation that
<nav>
<NavLink exact to="/">Home</NavLink>
<NavLink to="/about">About</NavLink>
<NavLink to="/blog">Blog</NavLink>
</nav>
{{#if match('/', { exact: true })}}
<Home/>
{{elseif match('/about')}}
<About/>
{{elseif match('/blog')}}
<Blog/>
{{/if}}
<script>
import { match } from 'svelte-routing';
import NavLink from 'svelte-routing/NavLink.html';
import Home from './components/Home.html';
import About from './components/About.html';
import Blog from './components/Blog.html';
export default {
components: {
NavLink,
Home,
About,
Blog
},
methods: {
match
}
};
</script> I will give this some more thought, and I'm open to suggestions! |
Looks good. Also FYI Rich is planning to allow for dynamic components hopefully very soon. sveltejs/svelte#640 |
I apologize for the extremely slow progress on this. I experimented with dynamic components after your suggestion @rob-balfre , and it seems to be exactly what is needed! Instead of just putting the children of <!-- Route.html -->
{{#if match !== null}}
{{#if component !== null}}
<:Component {component}/>
{{else}}
<slot></slot>
{{/if}}
{{/if}}
<!-- App.html -->
<Route exact path="/" component={{Home}} /> This way |
I added the option of rendering a route with a component in |
Thanks for sharing svelte-routing. Been playing around with it today and noticed this...
<Route path="/dashboard"><Dashboard /></Route>
Dashboard will always fire it's oncreate method even if the path isn't active.
The text was updated successfully, but these errors were encountered: