Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If an error has been dispatched already, we don't do anything else.
// If an error has been dispatched already but the query does not contain an error anymore,
// we remove the entry from the dispatchedErrors map.
// If an error has not been dispatched yet, we keep track of it and we dispatch it.
const queryResult = this.props[name];
if (queryResult) {
const hasPreviouslyDispatchedError = Boolean(
this.dispatchedErrors.get(name)
);
const hasQueryErrored = Boolean(queryResult.error);
if (hasPreviouslyDispatchedError && !hasQueryErrored) {
this.dispatchedErrors.delete(name);
}
if (!hasPreviouslyDispatchedError && hasQueryErrored) {
this.dispatchedErrors.set(name, queryResult.error);
this.context.store.dispatch(handleActionError(queryResult.error));
}
}
});
}
Sdk.Get.errorHandler = error =>
globalActions.handleActionError(error, 'sdk')(dispatch);
}}
Sdk.Get.errorHandler = error =>
globalActions.handleActionError(error, 'sdk')(dispatch);
}}