|
1 |
| -import { useMemo, useState, useEffect, useRef, useCallback } from 'react'; |
| 1 | +import { useMemo, useEffect, useRef, useCallback } from 'react'; |
2 | 2 | import { useSelector } from 'react-redux';
|
3 | 3 | import isEqual from 'lodash/isEqual';
|
4 | 4 | import difference from 'lodash/difference';
|
@@ -59,8 +59,10 @@ export const useReferenceArrayInputController = (
|
59 | 59 | // We store the current input value in a ref so that we are able to fetch
|
60 | 60 | // only the missing references when the input value changes
|
61 | 61 | const inputValue = useRef(input.value);
|
62 |
| - const [idsToFetch, setIdsToFetch] = useState(input.value); |
63 |
| - const [idsToGetFromStore, setIdsToGetFromStore] = useState(EmptyArray); |
| 62 | + const [idsToFetch, setIdsToFetch] = useSafeSetState(input.value); |
| 63 | + const [idsToGetFromStore, setIdsToGetFromStore] = useSafeSetState( |
| 64 | + EmptyArray |
| 65 | + ); |
64 | 66 | const referenceRecordsFromStore = useSelector((state: ReduxState) =>
|
65 | 67 | idsToGetFromStore.map(id => state.admin.resources[reference].data[id])
|
66 | 68 | );
|
@@ -186,7 +188,7 @@ export const useReferenceArrayInputController = (
|
186 | 188 | }, [setPagination, initialPage, initialPerPage]);
|
187 | 189 |
|
188 | 190 | // filter logic
|
189 |
| - const [queryFilter, setFilter] = useState(''); |
| 191 | + const [queryFilter, setFilter] = useSafeSetState(''); |
190 | 192 | const filterRef = useRef(defaultFilter);
|
191 | 193 | const [displayedFilters, setDisplayedFilters] = useSafeSetState<{
|
192 | 194 | [key: string]: boolean;
|
|
0 commit comments