Skip to content

feat: useCreateQuery (experimental) #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2023
Merged

feat: useCreateQuery (experimental) #10

merged 1 commit into from
Feb 13, 2023

Conversation

imp-dance
Copy link
Collaborator

Lets you use any function that returns a promise in your loader as if it was an RTK useQuery.

import {
  createLoader,
  useCreateQuery,
} from "@ryfylke-react/rtk-query-loader";

const loader = createLoader({
  queries: (userId: string) => {
    const query = useCreateQuery(async () => {
      const res = await fetch(`users/${userId}`);
      const json = await res.json();
      return json as SomeDataType;
      // dependency array
    }, [userId]);
    return [query] as const;
  },
});

@netlify
Copy link

netlify bot commented Feb 13, 2023

Deploy Preview for rtk-query-loader ready!

Name Link
🔨 Latest commit ba954f6
🔍 Latest deploy log https://app.netlify.com/sites/rtk-query-loader/deploys/63e97f0f465d4c00074ed85c
😎 Deploy Preview https://deploy-preview-10--rtk-query-loader.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@imp-dance imp-dance merged commit 525a820 into main Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant