Skip to content

Commit 0ea31c3

Browse files
authored
fix(explorer): show loader only on initial table data load (#3517)
1 parent 40aaf97 commit 0ea31c3

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

.changeset/three-seals-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/explorer": patch
3+
---
4+
5+
The loader in the Explore table now appears only during the initial data load. Additionally, a loading spinner has been added to the query submit button for non-live queries to indicate when a query is being refetched.

packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/TablesViewer.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ type Props = {
3737
export function TablesViewer({ table, query, isLiveQuery }: Props) {
3838
const { id: chainId } = useChain();
3939
const indexer = indexerForChainId(chainId);
40-
const {
41-
data: tableData,
42-
isLoading: isTDataLoading,
43-
isRefetching,
44-
isFetched,
45-
isError,
46-
error,
47-
} = useTableDataQuery({ table, query, isLiveQuery });
48-
const isLoading = isTDataLoading || isRefetching || !isFetched;
40+
const { data: tableData, isPending, isError, error } = useTableDataQuery({ table, query, isLiveQuery });
4941
const [globalFilter, setGlobalFilter] = useQueryState("filter", parseAsString.withDefault(""));
5042
const [sorting, setSorting] = useQueryState("sort", parseAsJson<SortingState>().withDefault(initialSortingState));
5143

@@ -129,20 +121,20 @@ export function TablesViewer({ table, query, isLiveQuery }: Props) {
129121
disabled={!tableData}
130122
/>
131123

132-
<ExportButton tableData={tableData} isLoading={isLoading} />
124+
<ExportButton tableData={tableData} isLoading={isPending} />
133125
</div>
134126

135127
<div
136128
className={cn("rounded-md border", {
137129
"border-red-400": isError,
138130
})}
139131
>
140-
{isLoading && (
132+
{isPending && (
141133
<div className="flex h-24 items-center justify-center">
142134
<LoaderIcon className="h-5 w-5 animate-spin" />
143135
</div>
144136
)}
145-
{!isLoading && (
137+
{!isPending && (
146138
<div className="relative w-full overflow-auto">
147139
<Table>
148140
<TableHeader>

0 commit comments

Comments
 (0)