File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -28,17 +28,23 @@ import {
2828} from " @ryfylke-react/rtk-query-loader" ;
2929
3030const loader = createLoader ({
31- queries : () => {
31+ useQueries : () => {
3232 const pokemon = useGetPokemon ();
3333 const currentUser = useGetCurrentUser ();
34- return [pokemon , currentUser ] as const ;
34+
35+ return {
36+ queries: {
37+ pokemon ,
38+ currentUser ,
39+ },
40+ };
3541 },
3642 onLoading : () => <div >Loading pokemon...</div >,
3743});
3844
39- const Pokemon = withLoader ((props , queries ) => {
40- const pokemon = queries [ 0 ] .data ;
41- const currentUser = queries [ 1 ] .data ;
45+ const Pokemon = withLoader ((props , loader ) => {
46+ const pokemon = loader . queries . pokemon .data ;
47+ const currentUser = loader . queries . currentUser .data ;
4248
4349 return (
4450 <div >
@@ -89,4 +95,5 @@ What if we could instead "join" these queries into one, and then just return ear
8995- [x] Easy to write re-usable loaders that can be abstracted away from the components
9096
9197## [ Documentation] ( https://rtk-query-loader.ryfylke.dev )
98+
9299## [ Quick Guide] ( https://rtk-query-loader.ryfylke.dev/Quick%20Guide/ )
You can’t perform that action at this time.
0 commit comments