question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle numbers when they are passed using toLocaleString function or provide a prop to format displayed numbers

See original GitHub issue

Describe the issue. What is the expected and unexpected behavior?

The Pagination component

<Pagination
      itemCount={props.itemCount}
      widgetId="pagination-options-menu-top"
      perPage={perPage}
      page={currentPage}
      variant={PaginationVariant.bottom}
      onSetPage={onSetPage}
      onPerPageSelect={onPerPageSelect}
    />

If I try to pass the itemCount as itemCount={props.itemCount.toLocaleString()} to display large numbers in human readable format, it shows the number correctly at one place but shows NaN at the second place. It’s understandable as the toLocaleString converted it to string and component is not able to handle it However, it would be great if it can handle that.

Is this a bug or enhancement? If this issue is a bug, is this issue blocking you or is there a work-around? Not blocking but there is no workaround either.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vratheecommented, Oct 1, 2020

@tlabaj Yes, I can send a MR.

0reactions
stale[bot]commented, Dec 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Number.prototype.toLocaleString() - JavaScript | MDN
This tests for a global Intl object, checks that it's not null and that it has a NumberFormat property that is a function....
Read more >
JavaScript: Number toLocaleString() method - TechOnTheNet
Determines the maximum number of fractional digits to display. It can be a value between 0 and 20.
Read more >
The complete guide to toLocaleString in Node.js
With the toLocaleString method, you can format numbers as currencies using the convention of the language you pass as the first argument.
Read more >
In React, how to format a number with commas?
I have a class which converts a number to either 31,312 or 31,312.00 . return value. toLocaleString(navigator. language, { ...
Read more >
typescript-cheatsheet - GitHub Pages
As in JavaScript, all numbers in TypeScript are floating point values. ... Think of abstract methods as methods that won't be passed down...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found