Skip to content

Commit

Permalink
Fix double callback post-import
Browse files Browse the repository at this point in the history
After uploading a list, the modal was being shown twice. Declaring the
constituent state dependencies separately fixed the issue.
  • Loading branch information
rylnd committed Jul 1, 2020
1 parent e39116c commit df70e5c
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,12 @@ export const ValueListsFormComponent: React.FC<ValueListsFormProps> = ({ onError
}, [importState.loading, files, importList, http, type]);

useEffect(() => {
const { error, loading, result } = importState;

if (!loading && result) {
handleSuccess(result);
} else if (!loading && error) {
handleError(error);
if (!importState.loading && importState.result) {
handleSuccess(importState.result);
} else if (!importState.loading && importState.error) {
handleError(importState.error);
}
}, [handleError, handleSuccess, importState]);
}, [handleError, handleSuccess, importState.error, importState.loading, importState.result]);

useEffect(() => {
return handleCancel;
Expand Down

0 comments on commit df70e5c

Please sign in to comment.