/task-show-on-error-fix (#1269)

* watch only the attributes from within params that we need from the TaskShow useEffect w/ burnettk

* do not watch addError from the callback to avoid re-renders w/ burnettk

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2024-03-25 16:07:26 +00:00 committed by GitHub
parent fed785b50c
commit fa241e1a01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 4 deletions

View File

@ -52,6 +52,12 @@ export default function TaskShow() {
const { addError, removeError } = useAPIError();
const addErrorCallback = useCallback((error: ErrorForDisplay) => {
addError(error);
// FIXME: not sure what to do about addError. adding it to this array causes the page to endlessly reload
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// if a user can complete a task then the for-me page should
// always work for them so use that since it will work in all cases
const navigateToInterstitial = useCallback(
@ -112,7 +118,7 @@ export default function TaskShow() {
};
const handleTaskFetchError = (error: ErrorForDisplay) => {
setAtLeastOneTaskFetchHasError(true);
addError(error);
addErrorCallback(error);
};
HttpService.makeCallToBackend({
@ -125,9 +131,12 @@ export default function TaskShow() {
successCallback: processTaskWithDataResult,
failureCallback: handleTaskFetchError,
});
// FIXME: not sure what to do about addError. adding it to this array causes the page to endlessly reload
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [params, processBasicTaskResult]);
}, [
params.task_id,
params.process_instance_id,
processBasicTaskResult,
addErrorCallback,
]);
// Before we auto-saved form data, we remembered what data was in the form, and then created a synthetic submit event
// in order to implement a "Save and close" button. That button no longer saves (since we have auto-save), but the crazy