Skip to content

Commit 9285a0c

Browse files
committed
docs: Updated docs
1 parent 934db62 commit 9285a0c

File tree

14 files changed

+102
-62
lines changed

14 files changed

+102
-62
lines changed

docs/docs/Advanced/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 7
33
---
44

55
# Advanced

docs/docs/Exports/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 5
2+
sidebar_position: 6
33
---
44

55
# Exports

docs/docs/Exports/use-create-query.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const loader = createLoader({
2727
});
2828
```
2929

30-
> You lose some great features from RTK query when using `useCreateQuery`.
31-
> If possible, try to stick to using actual queries, created from a `@reduxjs/toolkit` API.
32-
> You can look at this feature like an escape-hatch that allows you to pass other
33-
> data through the loader as well.
30+
:::caution
31+
You lose some great features from RTK query when using `useCreateQuery`.
32+
33+
When possible, try to stick to using actual queries, created from a `@reduxjs/toolkit` API.
34+
You can look at this feature like an escape-hatch that allows you to pass other
35+
data through the loader as well.
36+
:::

docs/docs/Features/extending.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ It's worth mentioning that queries and transform are linked in this context, mea
2424

2525
All other properties in the loader will overwrite as expected. You can, for example, just supply a new `onLoading`, or `onError`.
2626

27-
> You may extend _extended_ loaders, to create an inheritance model.
27+
:::info
28+
You may extend _extended_ loaders, to create an inheritance model.
29+
:::

docs/docs/Features/index.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 5
33
---
44

55
# Features
66

7-
Read more about various `rtk-query-loader` features.
7+
RTK Query Loader tries to give you all the flexibility you need to create reusable and extendable loaders.
8+
9+
- Supply multiple queries.
10+
- Supply queries that are [not from RTK](../Exports/use-create-query.md).
11+
- Supply queries that [don't affect loading state](defer-queries.md).
12+
- [Transform](./transforming.md) the queries to your desired output-format.
13+
- [Extend](./extending.md) existing loaders.
14+
- Re-use existing loaders

docs/docs/Quick Guide/add-queries.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export const userRouteLoader = baseLoader.extend({
4040
});
4141
```
4242

43-
**If you want to consume this loader through `withLoader`, you need to add the `queriesArg` argument**.
43+
:::caution Beware
44+
If you want to consume this loader through `withLoader`, you need to add the `queriesArg` argument. This supplies the loader with an argument piped from `props`.
45+
:::
46+
47+
### `queriesArg`
4448

4549
This argument transforms the consumer's props to the queries argument.
4650

docs/docs/Quick Guide/base-loader.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ sidebar_position: 1
66

77
A `Loader` can control the loading, fetch and error state views for consumer components.
88

9-
> Use a base loader to create sensible "fallback"/"default"-states for consumer components.
9+
:::tip
10+
Use a base loader to create sensible "fallback"/"default"-states for consumer components.
11+
:::
1012

1113
```tsx title="/src/loaders/baseLoader.tsx" {7-20}
1214
import {

docs/docs/Quick Guide/consume-loader.md renamed to docs/docs/Quick Guide/consume-loader.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
sidebar_position: 4
33
---
44

5+
import Tabs from "@theme/Tabs";
6+
import TabItem from "@theme/TabItem";
7+
58
# Consume the loader
69

7-
## Using `withLoader`
10+
<Tabs groupId="method" queryString>
11+
<Tab label="Using withLoader" value="withLoader">
12+
13+
A convenient wrapper that ensures that the component is only rendered when it has data.
814

9-
A convenient wrapper that ensures that the component is only rendered when it has data. This is definitely the preferred and optimal way to consume the loaders.
15+
This is definitely the preferred and optimal way to consume the loaders.
1016

11-
```tsx title="/src/routes/UserRoute.tsx" {8-22}
17+
```tsx {8-22}
1218
import { withLoader } from "@ryfylke-react/rtk-query-loader";
1319
import { userRouteLoader } from "../loaders/baseLoader";
1420

@@ -33,7 +39,8 @@ export const UserRoute = withLoader((props: Props, queries) => {
3339
}, userRouteLoader);
3440
```
3541

36-
## Using `useLoader`
42+
</Tab>
43+
<Tab label="Using useLoader" value="useLoader" default>
3744

3845
Every `Loader` contains an actual hook that you can call to run all the queries and aggregate their statuses as if they were just one joined query.
3946

@@ -58,3 +65,6 @@ const UserRoute = (props: Props) => {
5865
// ...
5966
};
6067
```
68+
69+
</Tab>
70+
</Tabs>

docs/docs/Quick Guide/extend-loader.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ export const userRouteLoader = baseLoader.extend({});
1414

1515
You can pass any argument from [`createLoader`](/Exports/create-loader) into [`Loader.extend`](/Features/extending).
1616

17+
:::info Separation of concerns
1718
Its up to you how much you want to separate logic here. Some examples would be...
1819

1920
- Co-locating loaders in a shared folder
2021
- Co-locating loaders in same file as component
2122
- Co-locating loaders in same directory but in a separate file from the component
2223

2324
I personally prefer to keep the loaders close to the component, either in a file besides it or directly in the file itself, and then keep a base loader somewhere else to extend from.
25+
:::

docs/docs/Quick Guide/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 4
33
---
44

55
# Quick guide
66

7-
Get started quickly by following these steps.
7+
`rtk-query-loader` is a tool that you can use to clean up your codebase and prevent duplicate code. The following guide will walk you through some of our recommended best practises for making the most out of this package.
8+
9+
1. [Create a base loader](./base-loader.md)
10+
2. [Extend the base loader](./extend-loader.md)
11+
3. [Add queries](./add-queries.md)
12+
4. [Consume the loader](./consume-loader.md)

0 commit comments

Comments
 (0)