Skip to content

Commit 27b4e0e

Browse files
committed
docs: More updates to docs
1 parent 2a3ffec commit 27b4e0e

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

docs/docs/Advanced/under-the-hood.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
How does `rtk-query-loader` work _under the hood_?
44

5+
## The underlying principles
6+
7+
1. We have a higher-order component (wrapper)
8+
2. We aggregate the status of a collection of queries that are run through a hook
9+
3. We conditionally render the appropriate states
10+
4. We pass the data to the consumer-component through the use of `React.forwardRef`
11+
12+
### Can't I just build this myself?
13+
14+
Yes you can, the concept itself is quite simple. But making it properly type-safe can be difficult, and this package has been thoroughly tested and thought out. And we do offer some killer [features](../Features/index.md).
15+
516
## Virtual DOM
617

718
Imagine you have this component, rendered through `withLoader`:
@@ -59,20 +70,3 @@ div
5970
## RTKLoader
6071

6172
`RTKLoader` simply receives the loader and component, and handles returning the correct state depending on the query. You can take a look at how this component behaves [in the codebase](https://github.com/ryfylke-react-as/rtk-query-loader/blob/main/src/RTKLoader.tsx).
62-
63-
## Custom `loaderComponent`
64-
65-
You could pass a custom `loaderComponent` to your loaders, if you'd like:
66-
67-
```typescript
68-
const CustomLoader = (props: CustomLoaderProps) => {
69-
// Handle rendering
70-
};
71-
72-
const loader = createLoader({
73-
loaderComponent: CustomLoader,
74-
// ...
75-
});
76-
```
77-
78-
This allows you to have really fine control over how the rendering of components using `withLoader` should work.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Custom `loaderComponent`
6+
7+
You could pass a custom `loaderComponent` to your loaders, if you'd like:
8+
9+
```typescript
10+
const CustomLoader = (props: CustomLoaderProps) => {
11+
// Handle rendering
12+
};
13+
14+
const loader = createLoader({
15+
loaderComponent: CustomLoader,
16+
// ...
17+
});
18+
```
19+
20+
:::tip
21+
This allows you to have really fine control over how the rendering of components using `withLoader` should work.
22+
:::

docs/docs/Features/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ sidebar_position: 5
77
RTK Query Loader tries to give you all the flexibility you need to create reusable and extendable loaders.
88

99
- Supply multiple queries.
10-
- Supply queries that are [not from RTK](../Exports/use-create-query.md).
1110
- Supply queries that [don't affect loading state](defer-queries.md).
1211
- [Transform](./transforming.md) the queries to your desired output-format.
1312
- [Extend](./extending.md) existing loaders.
1413
- Re-use existing loaders
14+
15+
And even if you don't use `RTK Query`...
16+
17+
- Supply queries that are [just promises](../Exports/use-create-query.md).
18+
- [Use with other data loading libraries](./other-libs.md)

docs/docs/Advanced/other-libs.md renamed to docs/docs/Features/other-libs.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
15
# Use with other libraries
26

3-
You can technically use RTK Query Loader with most other similar query-fetching libraries. This is possible through the use of resolvers.
7+
You can use RTK Query Loader with most other similar query-fetching libraries. This is possible through the use of _resolvers_.
8+
9+
:::note
10+
Although `rtk-query-loader` was build with `@reduxjs/toolkit` in mind, the underlying principles can be applied to any similar data loading solution. [Read more about how RTK Query Loader works under the hood](../Advanced/under-the-hood.md).
11+
:::
412

513
## Tanstack Query
614

0 commit comments

Comments
 (0)