Skip to content

Commit 2a444b9

Browse files
committed
version: 0.3.37
1 parent e247245 commit 2a444b9

File tree

3 files changed

+4
-59
lines changed

3 files changed

+4
-59
lines changed

README.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,6 @@ const Component = withLoader(
168168
2. `Loader`
169169
Return value of `createLoader`.
170170

171-
### Extending/customizing the loader
172-
173-
To use an existing loader but with maybe a different loading state, for example:
174-
175-
```tsx
176-
177-
const Component = withLoader(
178-
(props: Props, loaderData) => {
179-
// Can safely assume that loaderData and props are populated.
180-
const posts = loaderData.posts;
181-
182-
return posts.map(,,,);
183-
},
184-
postsLoader.extend({
185-
onLoading: (props) => <props.loader />,
186-
onFetching: (props) => <props.loader />,
187-
}),
188-
)
189-
190-
```
191-
192171
## createUseLoader
193172

194173
Creates only the hook for the loader, without the extra metadata like loading state.
@@ -247,38 +226,3 @@ const pokemonLoader = baseLoader.extend({
247226
```
248227

249228
New properties will overwrite existing.
250-
251-
**NOTE**:
252-
253-
> If the loader that you _extend from_ has a `transform` function, and you are change the `queries` function in the _extended_ loader, you might need to do the following fix to resolve the types correctly:
254-
255-
```typescript
256-
const baseLoader = createLoader({
257-
queries: () => [...],
258-
transform: () => {i_want: "this-format"},
259-
})
260-
261-
// This first example is extending a loader that has a transform.
262-
// It does not supply a new transform function
263-
const extendedOne = baseLoader.extend(({
264-
queries: () => [...],
265-
}))
266-
267-
type TestOne = InferLoaderData<typeof extendedOne>;
268-
// Resolves to: { i_want: string; }
269-
// which is incorrect. In reality it defaults to your list of queries.
270-
271-
// In this example, we supply a transform function as well:
272-
const extendedTwo = baseLoader.extend({
273-
queries: () => [...],
274-
transform: (q) => q, // This is essentially the default value
275-
});
276-
277-
type TestTwo = InferLoaderData<typeof extendedTwo>;
278-
// Resolves to: readonly [UseQueryResult<...>]
279-
// which is correct.
280-
```
281-
282-
> This is just a type mistake that will hopefully be fixed in the future. Both `extendedOne` and `extendedTwo` return the same format, but `extendedTwo` has the correct types.
283-
284-
## [**Contributing guidelines**](https://github.com/ryfylke-react-as/rtk-query-loader/blob/main/CONTRIBUTING.md)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ryfylke-react/rtk-query-loader",
3-
"version": "0.3.36",
3+
"version": "0.3.37",
44
"description": "Lets you create reusable, extendable RTK loaders for React components.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ export type Loader<
201201
LoaderComponent: Component<CustomLoaderProps>;
202202
};
203203

204-
/** Legacy/unused, for backwards compatibility */
205-
204+
/************************************************/
205+
/* Legacy/unused, for backwards compatibility */
206+
/************************************************/
206207
export type WithLoaderArgs<
207208
P extends unknown,
208209
R extends unknown,

0 commit comments

Comments
 (0)