Files
Tom Moor b72fd33e9c fix(editor): Use lazyWithRetry for shared editor lazy components (#13868)
Moves lazyWithRetry to shared/utils so the editor's ColorSwatch and
Mentions components can use it instead of React.lazy, avoiding the
Suspense reveal throttle once the chunk is loaded.
2026-09-23 20:50:37 -04:00

31 lines
933 B
TypeScript

import type { ColumnSort } from "@tanstack/react-table";
import { useCallback } from "react";
import { useHistory } from "react-router-dom";
import lazyWithRetry from "@shared/utils/lazyWithRetry";
import type { Props as TableProps, RowData } from "./Table";
const Table = lazyWithRetry(() => import("~/components/Table"));
export type Props<T> = Omit<TableProps<T>, "onChangeSort">;
export function SortableTable<T extends RowData>(props: Props<T>) {
const history = useHistory();
const handleChangeSort = useCallback(
(sort: ColumnSort) => {
const { pathname, search } = history.location;
const params = new URLSearchParams(search);
params.set("sort", sort.id);
params.set("direction", sort.desc ? "desc" : "asc");
history.replace({
pathname,
search: params.toString(),
});
},
[history]
);
return <Table onChangeSort={handleChangeSort} {...props} />;
}