diff --git a/utils/duckdb.ts b/utils/duckdb.ts index 64614f9..1e08116 100644 --- a/utils/duckdb.ts +++ b/utils/duckdb.ts @@ -8,7 +8,6 @@ import * as duckdb from "@duckdb/duckdb-wasm" import { AsyncDuckDB, DuckDBBundle } from "@duckdb/duckdb-wasm" import Worker from "web-worker" import path from "path" -import { useEffect, useState } from "react" const ENABLE_DUCK_LOGGING = false @@ -119,18 +118,6 @@ export async function loadParquet(path: string): Promise { }) } -/** - * Hook for loading a parquet file or URL; starts out `null`, gets populated asynchronously - */ -export function useParquet(url?: string): T[] | null { - const [data, setData] = useState(null) - useEffect(() => { - if (!url) return - loadParquet(url).then((data) => setData(data)) - }, []) - return data -} - /** * Convert [a byte array representing a Parquet file] to an array of records */ diff --git a/utils/useParquet.ts b/utils/useParquet.ts new file mode 100644 index 0000000..b0085c1 --- /dev/null +++ b/utils/useParquet.ts @@ -0,0 +1,15 @@ + +import { useEffect, useState } from "react" +import { loadParquet } from "./duckdb" + +/** + * Hook for loading a parquet file or URL; starts out `null`, gets populated asynchronously + */ +export function useParquet(url?: string): T[] | null { + const [data, setData] = useState(null) + useEffect(() => { + if (!url) return + loadParquet(url).then((data) => setData(data)) + }, []) + return data +}