Skip to content

Commit ff54c9e

Browse files
committed
feat: 0.3.25 onError is now passed a third argument, query which contains the joined rtk-query that has failed, allowing for use of the refetch method, etc.
1 parent ec23d88 commit ff54c9e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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.22",
3+
"version": "0.3.25",
44
"description": "Lets you create loaders that contain multiple RTK queries.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ export type CreateLoaderArgs<
9595
onLoading?: (props: P) => ReactElement;
9696
onError?: (
9797
props: P,
98-
error: FetchBaseQueryError | SerializedError
98+
error: FetchBaseQueryError | SerializedError,
99+
joinedQuery: UseQueryResult<undefined>
99100
) => ReactElement;
100101
onFetching?: (
101102
props: P,
@@ -113,7 +114,8 @@ export type Loader<
113114
onLoading?: (props: P) => ReactElement;
114115
onError?: (
115116
props: P,
116-
error: SerializedError | FetchBaseQueryError
117+
error: SerializedError | FetchBaseQueryError,
118+
joinedQuery: UseQueryResult<undefined>
117119
) => ReactElement;
118120
onFetching?: (
119121
props: P,

src/withLoader.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export const withLoader = <
2525
onError={
2626
args.onError
2727
? (error) =>
28-
args.onError?.(props, error) ?? (
29-
<React.Fragment />
30-
)
28+
args.onError?.(
29+
props,
30+
error,
31+
query as Types.UseQueryResult<undefined>
32+
) ?? <React.Fragment />
3133
: undefined
3234
}
3335
onSuccess={(data) => Component(props, data)}

0 commit comments

Comments
 (0)