react-table custom sortType not able to sort columns

909 Views Asked by At

I'm trying to define a custom sorting function in a column def using react-table . However, when using this custom function the table columns are not sortable. I think there is something incorrect with my syntax.

This works (I am able to sort the columns)

sortType: column.accessor === "myColumnId" ? "basic" : "alphanumeric"

This does not work (I am not able to sort any columns):

sortType: getWoSortType,

where getWoSortType looks like this:


// sort types
export const getWoSortType = (rowA, rowB, id) => {
  switch (id) {
    case "isolationPlans":
      return "basic";
    default:
      return "alphanumeric";
  }
};

I have tried debugging getWoSortType and everything looks correct, i. e. the values are defined and the correct cases are being reached. Why does it not work using this other syntax?

0

There are 0 best solutions below