diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index fb0eb70f68a..fda88a0835f 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -268,6 +268,7 @@ export function useTable( ): [readonly Prettify>[], boolean] { type UseTableRowType = RowType; const tableName = tableDef.name; + const accessorName = tableDef.accessorName; let whereClause: Expr> | undefined; if ( whereClauseOrCallbacks && @@ -313,7 +314,7 @@ export function useTable( if (!connection) { return [[], false]; } - const table = connection.db[tableName]; + const table = connection.db[accessorName]; const result: readonly Prettify[] = whereClause ? (Array.from(table.iter()).filter(row => evaluate(whereClause, row as UseTableRowType) @@ -321,7 +322,7 @@ export function useTable( : (Array.from(table.iter()) as Prettify[]); return [result, subscribeApplied]; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [connectionState, tableName, whereKey, subscribeApplied]); + }, [connectionState, accessorName, whereKey, subscribeApplied]); useEffect(() => { const connection = connectionState.getConnection()!; @@ -412,7 +413,7 @@ export function useTable( return () => {}; } - const table = connection.db[tableName]; + const table = connection.db[accessorName]; table.onInsert(onInsert); table.onDelete(onDelete); table.onUpdate?.(onUpdate); @@ -426,7 +427,7 @@ export function useTable( // eslint-disable-next-line react-hooks/exhaustive-deps [ connectionState, - tableName, + accessorName, whereKey, callbacks?.onDelete, callbacks?.onInsert,