Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 9 additions & 21 deletions tanstack-query-lite/react/ReactQueryDevtools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const ReactQueryDevtools = () => {

const queries = queryClient.getQueryCache().getAll();
const sortedQueries = [...queries].sort((a, b) => (a.queryHash > b.queryHash ? 1 : -1));
function renderStatus(status, isFetching, observers) {
if (isFetching) return <span className="text-blue-500">fetching</span>;
if (!observers.length) return <span className="text-gray-500">inactive</span>;
if (status === "success") return <span className="text-green-500">success</span>;
if (status === "error") return <span className="text-red-500">error</span>;
return null;
}


return (
<div className="fixed bottom-0 w-full overflow-scroll text-white bg-black divide-y-2 divide-gray-800 divide-solid">
Expand All @@ -24,27 +32,7 @@ const ReactQueryDevtools = () => {
return (
<div key={queryHash} className="p-2">
{JSON.stringify(queryKey, null, 2)}, {JSON.stringify({ staleTime, gcTime }, null, 2)} -{" "}
<span className="font-bold">
{(() => {
if (isFetching) {
return <span className="text-blue-500">fetching</span>;
}

if (!observers.length) {
return <span className="text-gray-500">inactive</span>;
}

if (status === "success") {
return <span className="text-green-500">success</span>;
}

if (status === "error") {
return <span className="text-red-500">error</span>;
}

return null;
})()}
</span>
Comment on lines -27 to -47
Copy link
Owner

@mugglim mugglim Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think current the code is more intuitive, even though it uses IIFE.
So, for now, I'd prefer to keep it as it is.

<span className="font-bold">{renderStatus(status, isFetching, observers)}</span>
</div>
);
})}
Expand Down