File tree Expand file tree Collapse file tree 4 files changed +7926
-7815
lines changed Expand file tree Collapse file tree 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 11{
22 "name" : " @ryfylke-react/rtk-query-loader" ,
3- "version" : " 0.3.26 " ,
3+ "version" : " 0.3.3 " ,
44 "description" : " Lets you create loaders that contain multiple RTK queries." ,
55 "main" : " ./dist/cjs/index.js" ,
66 "module" : " ./dist/esm/index.js" ,
2121 "url" : " https://github.com/ryfylke-react-as/rtk-query-loader/issues"
2222 },
2323 "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" : {
2628 "@reduxjs/toolkit" : " ^1.6.2" ,
2729 "react" : " ^18.2.0" ,
2830 "tslib" : " ^2.4.0"
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ export const withLoader = <
1818 const query = args . useLoader (
1919 ...( useLoaderArgs as Types . OptionalGenericArg < A > )
2020 ) ;
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+
2129 return (
2230 < RTKLoader
2331 query = { query }
@@ -32,11 +40,18 @@ export const withLoader = <
3240 ) ?? < React . Fragment />
3341 : undefined
3442 }
35- onSuccess = { ( data ) => Component ( props , data ) }
43+ onSuccess = { ( data ) => (
44+ < ForwardedComponent { ...props } ref = { data } />
45+ ) }
3646 onFetching = { args ?. onFetching ?.(
3747 props ,
3848 query . data
39- ? ( ) => Component ( props , query . data as R )
49+ ? ( ) => (
50+ < ForwardedComponent
51+ { ...props }
52+ ref = { query . data as R }
53+ />
54+ )
4055 : ( ) => < React . Fragment />
4156 ) }
4257 />
You can’t perform that action at this time.
0 commit comments