Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
react-table custom sorting using sortType not working for boolean values

I have a list of column definitions, where I want to update one of them to allow for sorting in a particular way.

I can not get it to work. The propert plans in the data is a boolean. The column definition for "plans" looks like this after my code underneath has been run: accessor: "plans" canSort: true header: "plans" sequence: 0 sortType: ƒ boolSort(rowA, rowB, columnId) type: "string"

Here is my go at it


let newCols = columns;

    if (columns.length > 0) {
      const filteredCols = columns.filter(c => c.accessor !== "plans");

      const boolSort = (rowA, rowB, columnId) => {
        const a = rowA.values[columnId].toString();
        const b = rowB.values[columnId].toString();
        return a > b ? 1 : -1;
      };

      const change = columns.find(c => c.accessor === "plans");
      if (change) {
        change.canSort = true;
        change.sortType = boolSort;
        newCols = [...filteredCols, change];
      }

Why does the sorting not work for this column now?

"react-table": "^7.0.0-beta.15",
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda