File tree 4 files changed +7926
-7815
lines changed
4 files changed +7926
-7815
lines changed Original file line number Diff line number Diff line change
1
+ src
2
+ testing-app
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @ryfylke-react/rtk-query-loader" ,
3
- "version" : " 0.3.26 " ,
3
+ "version" : " 0.3.3 " ,
4
4
"description" : " Lets you create loaders that contain multiple RTK queries." ,
5
5
"main" : " ./dist/cjs/index.js" ,
6
6
"module" : " ./dist/esm/index.js" ,
21
21
"url" : " https://github.com/ryfylke-react-as/rtk-query-loader/issues"
22
22
},
23
23
"homepage" : " https://github.com/ryfylke-react-as/rtk-query-loader#readme" ,
24
- "dependencies" : {
25
- "@types/react" : " ^18.0.21" ,
24
+ "devDependencies" : {
25
+ "@types/react" : " ^18.0.21"
26
+ },
27
+ "peerDependencies" : {
26
28
"@reduxjs/toolkit" : " ^1.6.2" ,
27
29
"react" : " ^18.2.0" ,
28
30
"tslib" : " ^2.4.0"
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ export const withLoader = <
18
18
const query = args . useLoader (
19
19
...( useLoaderArgs as Types . OptionalGenericArg < A > )
20
20
) ;
21
+
22
+ const ForwardedComponent = React . useCallback (
23
+ React . forwardRef (
24
+ Component as React . ForwardRefRenderFunction < R , P >
25
+ ) as unknown as Types . ComponentWithLoaderData < P , R > ,
26
+ [ ]
27
+ ) ;
28
+
21
29
return (
22
30
< RTKLoader
23
31
query = { query }
@@ -32,11 +40,18 @@ export const withLoader = <
32
40
) ?? < React . Fragment />
33
41
: undefined
34
42
}
35
- onSuccess = { ( data ) => Component ( props , data ) }
43
+ onSuccess = { ( data ) => (
44
+ < ForwardedComponent { ...props } ref = { data } />
45
+ ) }
36
46
onFetching = { args ?. onFetching ?.(
37
47
props ,
38
48
query . data
39
- ? ( ) => Component ( props , query . data as R )
49
+ ? ( ) => (
50
+ < ForwardedComponent
51
+ { ...props }
52
+ ref = { query . data as R }
53
+ />
54
+ )
40
55
: ( ) => < React . Fragment />
41
56
) }
42
57
/>
You can’t perform that action at this time.
0 commit comments