Implemented issue drag and drop
This commit is contained in:
@@ -14,6 +14,12 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
|
||||
variables: {},
|
||||
});
|
||||
|
||||
const setLocalData = useCallback(
|
||||
set => setState(currentState => ({ ...currentState, data: set(currentState.data) })),
|
||||
[],
|
||||
);
|
||||
const updateState = newState => setState(currentState => ({ ...currentState, ...newState }));
|
||||
|
||||
const wasCalledRef = useRef(false);
|
||||
|
||||
const paramsOrDataMemoized = useDeepCompareMemoize(paramsOrData);
|
||||
@@ -23,7 +29,6 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
|
||||
const makeRequest = useCallback(
|
||||
(newVariables = {}) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const updateState = newState => setState({ ...stateRef.current, ...newState });
|
||||
const variables = { ...stateRef.current.variables, ...newVariables };
|
||||
|
||||
if (!isCalledAutomatically || wasCalledRef.current) {
|
||||
@@ -57,6 +62,7 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
|
||||
...state,
|
||||
wasCalled: wasCalledRef.current,
|
||||
variables: { ...paramsOrDataMemoized, ...state.variables },
|
||||
setLocalData,
|
||||
},
|
||||
makeRequest,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user