Comments (10)
Sure, I will try ๐
from yrv.
Oh, nice question, I haven't look at it yet... I need some time to explore this, thank you!
from yrv.
Hi, now you can use the dynamic
and pending
attributes for that, e.g.
<Route dynamic={import('./your/component.js')} pending="Loading ..." />
from yrv.
from yrv.
Hello folks,
@pateketrueke thanks for sleek router.
I've been playing with it lately, but couldn't manage it to work dynamically. I did as specified above, but the component I try to load dynamically appears in the browser straight on load.
<Route path="/World" dynamic={ import(/* webpackChunkName: "async" */'@/components/async.svelte') } pending="Loading..."/>
On network it appears straight away.
Any help is appreciated.
from yrv.
but the component I try to load dynamically appears in the browser straight on load.
So the component is rendered regardless the current/active route? Or you say the network request should not be needed until actual usage?
Probably we need a special way to lazily inline the promise wheen needed (if the later), e.g.
<Route dynamic={() => import(...)} />
I think we can detect if its value is a function or a promise... based on that we can then delay the actual loading of the underlying component.
What do you think?
from yrv.
Thanks for swift reply!
I think this kind of functionality would be great. Tough may cause some misunderstanding of what exactly does dynamic prop.
May be it would be better to have "dynamic" prop only for async loading of components on demand, while "component" prop may have this functionality of getting either svelte component or import statement.
from yrv.
May be it would be better to have "dynamic" prop only for async loading of components on demand, while "component" prop may have this functionality of getting either svelte component or import statement.
I like that, would you mind on opening a PR with those changes?
from yrv.
Submitted PR:
Dynamic components
from yrv.
Resolved in Dynamic components.
from yrv.
Related Issues (20)
- Change the tagline to something more inclusive HOT 4
- on:click Doesn't work with href="" HOT 9
- How do we style Links (or the 'a' elements generated from them)? HOT 1
- Uncaught Error HOT 9
- Route with id param messes up stylesheet. HOT 2
- How to use hash based routes HOT 7
- Problem when use nested router with route path `/` HOT 2
- Support on:click for Link(button) without href HOT 3
- Support for cmd+click open in new window HOT 2
- Open in New Tab only works with Anchor Elements.
- Not working with more than 3 levels of nested routes HOT 3
- Typescript support and warnings on build HOT 11
- [Ops] Auto Publish NPM Package when push to master HOT 5
- Add in TS definitions to bundled artifacts when publishing
- Investigate Typedefs for router context HOT 1
- Jest tests started to fail after `main` package.json property got removed HOT 1
- Conditionals are broken on Routes HOT 3
- Implement option to cancel route change in yrv HOT 2
- Some routes don't render anymore after `disabled` or `condition` change HOT 1
- Standard Version deprecation and next steps HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yrv.