MCPcopy Create free account
hub / github.com/bvaughn/react-virtualized / MultiSortTable

Function MultiSortTable

lib/components/Table/Table.test.tsx:714–754  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

712 // #1585
713 it("should re-render when the sort criteria of createMultiSort are stored in React state", () => {
714 function MultiSortTable() {
715 // The sort criteria are stored in separate state values, as passed to the callback (not copied)
716 const [sortBy, setSortBy] = useState<string[]>(["name"]);
717 const [sortDirection, setSortDirection] = useState<
718 MultiSortCallbackParams["sortDirection"]
719 >({ name: "ASC" });
720 const [multiSort] = useState(() =>
721 createMultiSort(
722 ({ sortBy, sortDirection }) => {
723 setSortBy(sortBy);
724 setSortDirection(sortDirection);
725 },
726 { defaultSortBy: ["name"] }
727 )
728 );
729 const sortState = { sortBy, sortDirection };
730 return (
731 <Table
732 headerHeight={20}
733 height={100}
734 rowCount={list.size}
735 rowGetter={immutableRowGetter}
736 rowHeight={10}
737 sort={multiSort.sort}
738 width={200}
739 >
740 {["name", "email"].map((dataKey) => (
741 <Column
742 dataKey={dataKey}
743 headerRenderer={() =>
744 `${dataKey}:${sortState.sortDirection[dataKey] ?? "-"}:${
745 sortState.sortBy.indexOf(dataKey) + 1
746 }`
747 }
748 key={dataKey}
749 width={100}
750 />
751 ))}
752 </Table>
753 );
754 }
755
756 render(<MultiSortTable />);
757 const headers = () =>

Callers

nothing calls this directly

Calls 1

createMultiSortFunction · 0.90

Tested by

no test coverage detected