Bug/i118n flicker (#2609)

* Fix Global Flicker

* Fixes Flicker + Null return

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
pull/2446/head^2
sean-brydon 2022-04-26 01:26:13 +01:00 committed by GitHub
parent 10e796f956
commit 7c12bb1e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -64,7 +64,6 @@ export function QueryCell<TData, TError extends ErrorLike>(
opts: QueryCellOptionsNoEmpty<TData, TError> | QueryCellOptionsWithEmpty<TData, TError>
) {
const { query } = opts;
if (query.status === "success") {
if ("empty" in opts && (query.data == null || (Array.isArray(query.data) && query.data.length === 0))) {
return opts.empty(query);
@ -78,11 +77,13 @@ export function QueryCell<TData, TError extends ErrorLike>(
)
);
}
const StatusLoader = opts.customLoader || <Loader />; // Fixes edge case where this can return null form query cell
if (query.status === "loading") {
return opts.loading?.(query) ?? opts.customLoader ? opts.customLoader : <Loader />;
return opts.loading?.(query) ?? StatusLoader;
}
if (query.status === "idle") {
return opts.idle?.(query) ?? opts.customLoader ? opts.customLoader : <Loader />;
return opts.idle?.(query) ?? StatusLoader;
}
// impossible state
return null;