Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!