<Loading>
💚Contributions welcome to implement the
+Loadingsetting forvike-vueandvike-solid.
The +Loading setting adds <Suspense> fallbacks, with the purpose of showing loading animations.
// pages/+Loading.jsx
export default {
layout: LoadingLayout,
component: LoadingComponent
}
function LoadingLayout() {
// Shown when a page or layout is loading
return <div>Loading...</div>
}
function LoadingComponent() {
// Shown when a component is loading
return <div>Loading...</div>
}// pages/+Loading.tsx
export default {
layout: LoadingLayout,
component: LoadingComponent
}
function LoadingLayout() {
// Shown when a page or layout is loading
return <div>Loading...</div>
}
function LoadingComponent() {
// Shown when a component is loading
return <div>Loading...</div>
}This is how +Loading is embedded:
<Suspense fallback={Loading.layout}> ⟸ component defined by +Loading.layout
<Layout> ⟸ component defined by +Layout
<Page> ⟸ component defined by +Page
{/* ... */}
<Suspense fallback={Loading.component}> ⟸ component defined by +Loading.component
<SomeComponent />
</Suspense>
{/* ... */}
</Page>
</Layout>
</Suspense>This means that
+Loadingis only used if components suspend. Consequently:
- If your app doesn't include any suspending components, then
+Loadinghas no effect.- If you use
+data, then+Loadinghas no effect — because+datapauses the entire rendering process (it doesn't suspend any component).The
+Loadingcomponent is commonly used byvike-react-queryandvike-react-apollousers, as these extensions suspend components.
Default
The default Loading.component is:
This is the default loading animation. Its width is
100% of the parent (here the parent's width is artificially set to 400px). Its height is width * 0.4.If you want to show a different loading animation, then define Loading.component in order to override the default.