From cb1fe8bb6f818731a273865546d2f90201caabb3 Mon Sep 17 00:00:00 2001 From: Kali Charan Reddy Jonna <43421621+kalijonn@users.noreply.github.com> Date: Mon, 11 Dec 2023 20:13:14 +0530 Subject: [PATCH] docs: update to v5 syntax (#57) * docs: update to v5 syntax * docs: update isLoading to isPending to be more consistent with RQ docs --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc9cf97..c92f2c5 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,17 @@ You can incrementally adopt `jotai-tanstack-query` in your app. It's not an all ```jsx # existing useQueryHook - const { data, isLoading, isError } = useQuery('todos', () => fetch('/todos')); + const { data, isPending, isError } = useQuery({ + queryKey: ['todos'], + queryFn: fetchTodoList + }); # jotai-tanstack-query const todosAtom = atomWithQuery(() => ({ queryKey: ['todos'], })) - const [{ data, isLoading, isError }] = useAtom(todosAtom) + const [{ data, isPending, isError }] = useAtom(todosAtom) ``` @@ -410,7 +413,7 @@ In the previous version of `jotai-tanstack-query`, the query atoms `atomsWithQue #### atomWithQuery and atomWithInfiniteQuery - `dataAtom` was used to access the actual data (`TData`). -- `statusAtom` provided the status object (`QueryObserverResult`), which included additional attributes like `isLoading`, `isError`, etc. +- `statusAtom` provided the status object (`QueryObserverResult`), which included additional attributes like `isPending`, `isError`, etc. In v0.8.0, they have been replaced by `atomWithQuery` and `atomWithInfiniteQuery` to return only a single `dataAtom`. This `dataAtom` now directly provides the `QueryObserverResult`, aligning it closely with the behavior of Tanstack Query's bindings. @@ -422,7 +425,7 @@ To migrate to the new version, replace the separate `dataAtom` and `statusAtom` - const [status] = useAtom(statusAtom); + const dataAtom = atomWithQuery(/* ... */); -+ const [{ data, isLoading, isError }] = useAtom(dataAtom); ++ const [{ data, isPending, isError }] = useAtom(dataAtom); ``` #### atomWithMutation