react-number-format icon indicating copy to clipboard operation
react-number-format copied to clipboard

Difference between NumericFormat component and numericFormatter function

Open thiengo105 opened this issue 2 years ago • 4 comments

Describe the issue and the actual behavior

numericFormatter function should return the same value as NumberFormat component with the same props. image

Describe the expected behavior

numericFormatter should return 3.91 instead of 3.90

Provide a CodeSandbox link illustrating the issue

https://codesandbox.io/p/sandbox/react-number-format-gnsqpq

Provide steps to reproduce this issue

use the following props to pass to numericFormatter function and NumerFormat component:

value = 3.9082;
decimalScale = 2;

Please check the browsers where the issue is seen

  • [x] Chrome
  • [ ] Chrome (Android)
  • [ ] Safari (OSX)
  • [ ] Safari (iOS)
  • [ ] Firefox
  • [ ] Firefox (Android)

thiengo105 avatar Oct 19 '23 04:10 thiengo105

Also numericFormatter doesnt apply mapToRadix property

portare avatar May 15 '24 14:05 portare

Same problem with version 5.4.0. The parameter valueIsNumericString doesn't change anything.

RifatF avatar Jun 05 '24 11:06 RifatF

Here is the reason https://github.com/s-yadav/react-number-format/blob/master/src/numeric_format.tsx#L478 NumericFormat Component round value before formatting it with numericFormatter function

AI111 avatar Jun 17 '24 13:06 AI111