Skip to content

Commit 650b36e

Browse files
committed
adjust sql queries hooks return types
1 parent addec31 commit 650b36e

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function Explorer() {
2121
const indexer = indexerForChainId(chainId);
2222
const [isLiveQuery, setIsLiveQuery] = useState(false);
2323
const [{ pageSize }, setPagination] = usePaginationState();
24-
const { query, setQuery } = useSQLQueryState();
24+
const [query, setQuery] = useSQLQueryState();
2525
const [selectedTableId] = useQueryState("tableId");
2626
const prevSelectedTableId = usePrevious(selectedTableId);
2727
const { data: tables } = useTablesQuery();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function SQLEditor({ table, isLiveQuery, setIsLiveQuery }: Props) {
3030
const [isFocused, setIsFocused] = useState(false);
3131
const [isUserTriggeredRefetch, setIsUserTriggeredRefetch] = useState(false);
3232
const [pagination, setPagination] = usePaginationState();
33-
const { query, setQuery } = useSQLQueryState();
33+
const [query, setQuery] = useSQLQueryState();
3434

3535
const validateQuery = useQueryValidator(table);
3636
const {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Props = {
5151
export function TablesViewer({ table, isLiveQuery }: Props) {
5252
const { id: chainId } = useChain();
5353
const indexer = indexerForChainId(chainId);
54-
const { query, setQuery } = useSQLQueryState();
54+
const [query, setQuery] = useSQLQueryState();
5555
const [globalFilter, setGlobalFilter] = useQueryState("filter", parseAsString.withDefault(""));
5656
const [sorting, setSorting] = useQueryState("sort", parseAsJson<SortingState>().withDefault(initialSortingState));
5757
const [pagination, setPagination] = usePaginationState();
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { parseAsString, useQueryState } from "nuqs";
22

3-
export function useSQLQueryState() {
3+
type UseSQLQueryStateReturn = [string, (value: string) => void];
4+
5+
export function useSQLQueryState(): UseSQLQueryStateReturn {
46
const [query, setQuery] = useQueryState("query", parseAsString.withDefault(""));
5-
return {
6-
query: decodeURIComponent(query),
7-
setQuery: (value: string) => setQuery(encodeURIComponent(value)),
8-
};
7+
return [decodeURIComponent(query), (value: string) => setQuery(encodeURIComponent(value))];
98
}

0 commit comments

Comments
 (0)