Skip to content

Commit 98d00c7

Browse files
authored
Merge pull request marmelab#4829 from marmelab/fix-refresh-cache
Fix refresh button breaks useGetList result with application cache
2 parents 8b04ff8 + adf365b commit 98d00c7

File tree

5 files changed

+4
-5
lines changed

5 files changed

+4
-5
lines changed

packages/ra-core/src/controller/useEditController.ts

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const useEditController = (props: EditProps): EditControllerProps => {
7373
const refresh = useRefresh();
7474
const version = useVersion();
7575
const { data: record, loading, loaded } = useGetOne(resource, id, {
76-
version, // used to force reload
7776
action: CRUD_GET_ONE,
7877
onFailure: () => {
7978
notify('ra.notification.item_doesnt_exist', 'warning');

packages/ra-core/src/controller/useListController.ts

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ const useListController = <RecordType = Record>(
142142
{ ...query.filter, ...filter },
143143
{
144144
action: CRUD_GET_LIST,
145-
version,
146145
onFailure: error =>
147146
notify(
148147
typeof error === 'string'

packages/ra-core/src/controller/useShowController.ts

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const useShowController = (props: ShowProps): ShowControllerProps => {
5555
const refresh = useRefresh();
5656
const version = useVersion();
5757
const { data: record, loading, loaded } = useGetOne(resource, id, {
58-
version, // used to force reload
5958
action: CRUD_GET_ONE,
6059
onFailure: () => {
6160
notify('ra.notification.item_doesnt_exist', 'warning');

packages/ra-core/src/dataProvider/useQuery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import useDataProviderWithDeclarativeSideEffects from './useDataProviderWithDecl
6969
const useQuery = (query: Query, options: QueryOptions = {}): UseQueryValue => {
7070
const { type, resource, payload } = query;
7171
const { withDeclarativeSideEffectsSupport, ...rest } = options;
72-
const [state, setState] = useSafeSetState({
72+
const [state, setState] = useSafeSetState<UseQueryValue>({
7373
data: undefined,
7474
error: null,
7575
total: null,

packages/ra-core/src/dataProvider/useQueryWithStore.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useSelector } from 'react-redux';
33
import isEqual from 'lodash/isEqual';
44

55
import useDataProvider from './useDataProvider';
6+
import useVersion from '../controller/useVersion';
67
import getFetchType from './getFetchType';
78
import { useSafeSetState } from '../util/hooks';
89
import { ReduxState } from '../types';
@@ -120,7 +121,8 @@ const useQueryWithStore = (
120121
loaded: boolean;
121122
} => {
122123
const { type, resource, payload } = query;
123-
const requestSignature = JSON.stringify({ query, options });
124+
const version = useVersion(); // used to allow force reload
125+
const requestSignature = JSON.stringify({ query, options, version });
124126
const requestSignatureRef = useRef(requestSignature);
125127
const data = useSelector(dataSelector);
126128
const total = useSelector(totalSelector);

0 commit comments

Comments
 (0)