Skip to content

Commit dd25f59

Browse files
committed
docs: file names
1 parent 95c98a4 commit dd25f59

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/data-loaders/index.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Data loaders streamline any asynchronous state management with Vue Router, like **Data Fetching**. Adopting Data loaders ensures a consistent and efficient way to manage data fetching in your application. Keep all the benefits of using libraries like [Pinia Colada](./colada/) or [Apollo](./apollo/) and integrate them seamlessly with client-side navigation.
44

5-
This is achieved by extracting the loading logic **outside** of the component `setup` (unlike `<Suspense>`). This way, the loading logic can be executed independently of the component lifecycle, and the component can focus on rendering the data. Data Loaders are automatically collected and awaited within a navigation guard, ensuring the data is ready before rendering the component.
5+
This is achieved by extracting the loading logic **outside** of the component `setup` (unlike `<Suspense>`). This way, the loading logic can be executed independently of the component life cycle, and the component can focus on rendering the data. Data Loaders are automatically collected and awaited within a navigation guard, ensuring the data is ready before rendering the component.
66

77
## Features
88

@@ -46,9 +46,11 @@ There are different data loaders implementation, the most simple one is the [Bas
4646

4747
Loaders are [composables](https://vuejs.org/guide/reusability/composables.html) defined through a `defineLoader` function like `defineBasicLoader` or `defineColadaLoader`. They are _used_ in the component `setup` to extract the needed information.
4848

49-
To get started, _define_ and _export_ a loader from a page:
49+
To get started, _define_ and _**export**_ a loader from a **page** component:
5050

51-
```vue{2,5-7,11-16} twoslash
51+
::: code-group
52+
53+
```vue{2,5-7,11-16} twoslash [src/pages/users/[id].vue]
5254
<script lang="ts">
5355
import 'unplugin-vue-router/client'
5456
import './typed-router.d'
@@ -84,6 +86,8 @@ const {
8486
</template>
8587
```
8688

89+
:::
90+
8791
The loader will automatically run when the route changes, for example when navigating to `/users/1`, even when coming from `/users/2`, the loader will fetch the data and delay the navigation until the data is ready.
8892

8993
On top of that, you are free to _reuse_ the returned composable `useUserData` in any other component, and it will automatically share the same data fetching instance.

0 commit comments

Comments
 (0)