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

[Doc] Fix dataProvider hooks incorrectly document error state as loaded=true instead of false #6252

Merged
merged 2 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ This object updates according to the request state:

- start: `{ loading: true, loaded: false }`
- success: `{ data: [data from response], total: [total from response], loading: false, loaded: true }`
- error: `{ error: [error from response], loading: false, loaded: true }`
- error: `{ error: [error from response], loading: false, loaded: false }`

As a reminder, here are the read query types handled by Data Providers:

Expand Down Expand Up @@ -228,7 +228,7 @@ This object updates according to the request state:
- mount: `{ loading: false, loaded: false }`
- mutate called: `{ loading: true, loaded: false }`
- success: `{ data: [data from response], total: [total from response], loading: false, loaded: true }`
- error: `{ error: [error from response], loading: false, loaded: true }`
- error: `{ error: [error from response], loading: false, loaded: false }`

You can destructure the return value of the `useMutation` hook as `[mutate, { data, total, error, loading, loaded }]`.

Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useMutation, { MutationOptions, Mutation } from './useMutation';
* - initial: [create, { loading: false, loaded: false }]
* - start: [create, { loading: true, loaded: false }]
* - success: [create, { data: [data from response], loading: false, loaded: true }]
* - error: [create, { error: [error from response], loading: false, loaded: true }]
* - error: [create, { error: [error from response], loading: false, loaded: false }]
*
* @param resource The resource name, e.g. 'posts'
* @param data The data to initialize the new record with, e.g. { title: 'hello, world' }
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useMutation, { MutationOptions, Mutation } from './useMutation';
* - initial: [deleteOne, { loading: false, loaded: false }]
* - start: [deleteOne, { loading: true, loaded: false }]
* - success: [deleteOne, { data: [data from response], loading: false, loaded: true }]
* - error: [deleteOne, { error: [error from response], loading: false, loaded: true }]
* - error: [deleteOne, { error: [error from response], loading: false, loaded: false }]
*
* @param resource The resource name, e.g. 'posts'
* @param id The resource identifier, e.g. 123
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useDeleteMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useMutation, { MutationOptions, Mutation } from './useMutation';
* - initial: [deleteMany, { loading: false, loaded: false }]
* - start: [deleteMany, { loading: true, loaded: false }]
* - success: [deleteMany, { data: [data from response], loading: false, loaded: true }]
* - error: [deleteMany, { error: [error from response], loading: false, loaded: true }]
* - error: [deleteMany, { error: [error from response], loading: false, loaded: false }]
*
* @param resource The resource name, e.g. 'posts'
* @param ids The resource identifiers, e.g. [123, 456]
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultData = {};
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from store], ids: [ids from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetMainList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const defaultData = {};
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from store], ids: [ids from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const DataProviderOptions = { action: CRUD_GET_MANY };
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetManyReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface UseGetManyReferenceOptions {
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from store], ids: [ids from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetMatching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const referenceSource = (resource, source) => `${resource}@${source}`;
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from store], ids: [ids from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useGetOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useQueryWithStore } from './useQueryWithStore';
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { DeclarativeSideEffect } from './useDeclarativeSideEffects';
* - mount: [mutate, { loading: false, loaded: false }]
* - mutate called: [mutate, { loading: true, loaded: false }]
* - success: [mutate, { data: [data from response], total: [total from response], loading: false, loaded: true }]
* - error: [mutate, { error: [error from response], loading: false, loaded: true }]
* - error: [mutate, { error: [error from response], loading: false, loaded: false }]
*
* The mutate function accepts the following arguments
* - {Object} query
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { DataProviderQuery, Refetch } from './useQueryWithStore';
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* @param {Object} query
* @param {string} query.type The method called on the data provider, e.g. 'getList', 'getOne'. Can also be a custom method if the dataProvider supports is.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useQueryWithStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const defaultIsDataLoaded = (data: any): boolean => data !== undefined;
*
* - start: { loading: true, loaded: false }
* - success: { data: [data from response], total: [total from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: true }
* - error: { error: [error from response], loading: false, loaded: false }
*
* This hook will return the cached result when called a second time
* with the same parameters, until the response arrives.
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useMutation, { MutationOptions, Mutation } from './useMutation';
* - initial: [update, { loading: false, loaded: false }]
* - start: [update, { loading: true, loaded: false }]
* - success: [update, { data: [data from response], loading: false, loaded: true }]
* - error: [update, { error: [error from response], loading: false, loaded: true }]
* - error: [update, { error: [error from response], loading: false, loaded: false }]
*
* @param resource The resource name, e.g. 'posts'
* @param id The resource identifier, e.g. 123
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/useUpdateMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useMutation, { MutationOptions, Mutation } from './useMutation';
* - initial: [updateMany, { loading: false, loaded: false }]
* - start: [updateMany, { loading: true, loaded: false }]
* - success: [updateMany, { data: [data from response], loading: false, loaded: true }]
* - error: [updateMany, { error: [error from response], loading: false, loaded: true }]
* - error: [updateMany, { error: [error from response], loading: false, loaded: false }]
*
* @param resource The resource name, e.g. 'posts'
* @param ids The resource identifiers, e.g. [123, 456]
Expand Down