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

116
Vistas
How to convert decimal number from the accessor to react-table?

I am using react table. On my data, I have fields that have decimal numbers. I need to apply the function of round off on the data of the decimal numbers. I hope you could help me. Thank you

   const columns = useMemo(
        () => [
          {
            Header: 'Rank',
            id: 'index',
            accessor: (function (_row, i) { return i + 1; })
          
        },
        
          {
            Header: "Username",
            accessor: "username"
          },
          {
            Header: "Score",
            accessor: 'score',
            Cell: (row) => {
              return <div>{Math.round(row)}</div>;
            },
          },
          
        ],
        []
      );
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

use Math.ceil() if you want to round a number up to the next largest integer

about 4 years ago · Juan Pablo Isaza Denunciar

0

The function passed to Cell takes the first argument as an object with more data. To round the number by passing a funciton to Cell, use:

Cell: (obj) => Math.round(obj.value)

Or pass a function to the accessor:

accessor: (obj) => Math.round(obj.score)
about 4 years ago · Juan Pablo Isaza Denunciar
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