const idAtom = atom(async (get) => {
await new Promise((resolve) => setTimeout(resolve, 100));
return 1;
});
// Typing error here because of using async
// I need async to await get id from atom id
const [userAtom] = atomsWithQuery(async (get) => {
const id = await get(idAtom);
return {
queryKey: ["getUser", id],
queryFn: async () => await fetch("https://reqres.in/api/users/" + id)
};
});
Now it returns typing error
Reproduction link:
https://codesandbox.io/s/nifty-kirch-sg309h?file=/src/App.tsx
Thank you