Skip to content
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

Update documentation for react-query v5 #9481

Merged
merged 18 commits into from
Dec 15, 2023
Merged

Update documentation for react-query v5 #9481

merged 18 commits into from
Dec 15, 2023

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Nov 29, 2023

No description provided.

Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, incredible work ! (even though it's only like 1% of #9473 😅 )

docs/Admin.md Outdated Show resolved Hide resolved
docs/DataProviders.md Outdated Show resolved Hide resolved
docs/DataProviders.md Show resolved Hide resolved
docs/ReferenceArrayField.md Show resolved Hide resolved
@fzaninotto
Copy link
Member

fzaninotto commented Dec 8, 2023

We need to mention the change in keepPreviousData(cf #9473 (comment)) and the fact that queries can no longer return undefined in the upgrade guide

@fzaninotto
Copy link
Member

We also need to mention calltime vs definition time side effects

#9473 (comment)

@fzaninotto
Copy link
Member

The minimal version for mui is now 5.14.18, it could be mentioned in the upgrade guide

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the "Query Options" sections, we now need to explain the syntax of onSuccess, onError, and onSettled since the react-query doc doesn't mention them anymore

@fzaninotto
Copy link
Member

All the controllers and contexts have changed, too

@fzaninotto
Copy link
Member

There are many more instances of isLoading in the doc. I did replace some, but there are many left that should be replaced by isPending.

@djhi djhi added WIP Work In Progress and removed RFR Ready For Review labels Dec 8, 2023
@djhi
Copy link
Contributor Author

djhi commented Dec 8, 2023

The minimal version for mui is now 5.14.18, it could be mentioned in the upgrade guide

I forgot to revert that change in the #9473 PR. Will do so now

Base automatically changed from yarn-4 to next December 13, 2023 14:24
@djhi djhi added RFR Ready For Review and removed WIP Work In Progress labels Dec 13, 2023
@fzaninotto
Copy link
Member

I think we should still use the name "React Query" when referring to TanStack's React Query.

docs/Actions.md Outdated
};
```

## Query Options

The data provider method hooks (like `useGetOne`) and react-query's hooks (like `useQuery`) accept a query options object as the last argument. This object can be used to modify the way the query is executed. There are many options, all documented [in the react-query documentation](https://tanstack.com/query/v3/docs/react/reference/useQuery):
The data provider method hooks (like `useGetOne`) and react-query's hooks (like `useQuery`) accept a query options object as the last argument. This object can be used to modify the way the query is executed. There are many options, all documented [in the react-query documentation](https://tanstack.com/query/v5/docs/react/reference/useQuery):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many options, all documented in the react-query documentation:

This is not true for the onXXX methods, so I think we should extract their explanation

Also, we already have a section called "Success and Error Side Effects", perhaps we should reorganize this chapter?

docs/Actions.md Outdated
'users',
{ id: record.id },
{ onSettled: (data, error) => console.log(data, error) }
);
if (isLoading) { return <Loading />; }
if (isPending) { return <Loading />; }
if (error) { return <p>ERROR</p>; }
return <div>User {data.username}</div>;
};
```

We won't re-explain all these options here, but we'll focus on the most useful ones in react-admin.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence feels misplaced in the new doc

docs/Actions.md Outdated
Comment on lines 307 to 311
- `onSuccess(data, variables, context)`: The `onSuccess` function is called when the query returns. It receives the query data, the [query variables](https://tanstack.com/query/latest/docs/react/guides/query-functions#query-function-variables) and the [query context](https://tanstack.com/query/latest/docs/react/guides/query-functions#queryfunctioncontext).

- `onError(error, variables, context)`: The `onSuccess` function is called when the query fails. It receives the error, the [query variables](https://tanstack.com/query/latest/docs/react/guides/query-functions#query-function-variables) and the [query context](https://tanstack.com/query/latest/docs/react/guides/query-functions#queryfunctioncontext).

- `onSettled(data, error, variables, context)`: The `onSuccess` function is called after the query either succeeded or failed. It receives the query data (can be `undefined` if the query failed), the error (can be `undefined` when the query succeeded), the [query variables](https://tanstack.com/query/latest/docs/react/guides/query-functions#query-function-variables) and the [query context](https://tanstack.com/query/latest/docs/react/guides/query-functions#queryfunctioncontext).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add an example usage for each of these, with real use cases (e.g. notification, cache invalidation, etc)

Comment on lines 69 to 70
isPending, // boolean that is true until the data is fetched for the first time
isPending, // boolean that is true until the data is available for the first time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double isPending

Comment on lines 30 to 33
const { data, isPending } = useListContext();
const { data, isPending } = useListContext();
if (isPending) return null;
if (isPending) return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it doubled?

docs/Actions.md Outdated Show resolved Hide resolved
docs/Actions.md Outdated Show resolved Hide resolved
docs/Actions.md Outdated Show resolved Hide resolved
docs/Actions.md Outdated Show resolved Hide resolved
docs/Actions.md Outdated Show resolved Hide resolved
docs/Actions.md Outdated Show resolved Hide resolved
docs/Admin.md Outdated Show resolved Hide resolved
docs/Features.md Outdated Show resolved Hide resolved
docs/Upgrade.md Outdated Show resolved Hide resolved
docs/useListController.md Outdated Show resolved Hide resolved
djhi and others added 2 commits December 14, 2023 16:17
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
docs/Actions.md Outdated Show resolved Hide resolved
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
@fzaninotto fzaninotto merged commit 33a211f into next Dec 15, 2023
1 of 4 checks passed
@fzaninotto fzaninotto deleted the react-query-v5-doc branch December 15, 2023 10:50
@fzaninotto fzaninotto added this to the 5.0.0 milestone Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants