mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Merge pull request #8267 from mabashian/8252-jt-tabs-reload
Reset error/result only after the next request has resolved to prevent render flickering Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -38,18 +38,16 @@ export default function useRequest(makeRequest, initialValue) {
|
|||||||
request: useCallback(
|
request: useCallback(
|
||||||
async (...args) => {
|
async (...args) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
if (isMounted.current) {
|
|
||||||
setResult(initialValue);
|
|
||||||
setError(null);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const response = await makeRequest(...args);
|
const response = await makeRequest(...args);
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setResult(response);
|
setResult(response);
|
||||||
|
setError(null);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setError(err);
|
setError(err);
|
||||||
|
setResult(initialValue);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user