Skip to content

Commit

Permalink
docs: update to v5 syntax (#57)
Browse files Browse the repository at this point in the history
* docs: update to v5 syntax

* docs: update isLoading to isPending to be more consistent with RQ docs
  • Loading branch information
kalijonn authored Dec 11, 2023
1 parent 3fb9561 commit cb1fe8b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

```

Expand Down Expand Up @@ -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<TData, TError>`), which included additional attributes like `isLoading`, `isError`, etc.
- `statusAtom` provided the status object (`QueryObserverResult<TData, TError>`), 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<TData, TError>`, aligning it closely with the behavior of Tanstack Query's bindings.

Expand All @@ -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
Expand Down

0 comments on commit cb1fe8b

Please sign in to comment.