react-number-format
react-number-format copied to clipboard
cutTrailingZeros prop added to the component
added new prop => cutTrailingZeros (number) => if passed, then it will look for, and cut, ALL trailing zeros in the decimal part of the number, stopping at cutTrailingZeros decimal point.
So, in code, cutTrailingZeros is also used to determine the number of decimal places to leave intact when cutting trailing zeros. It's up to the developer, currently, to take care that the cutTrailingZeros prop's value isn't greater than decimalScale value (if such is used)
In case both decimalScale and cutTrailingZero props are used, if cutTrailingZero > decimalScale and fixedDecimal is used, it will display cutTrailingZero amount of decimals instead of decimalScale amount of decimals.
examples where this prop might be useful: e.g. 123,456.780 and cutTrailingZeros = 2 (because let's say that, while cutting trailing zeros, we still do want to keep at least 2 decimals and cut all trailing zeros after 2nd decimal place) then the result will be => 123,456.78 but if 123,456.780 and cutTrailingZeros = 3 (because let's say that, while cutting trailing zeros, we still do want to keep at least 3 decimals and cut all trailing zeros after 3rd decimal place) then the result will be => 123,456.780 .
Github issue that this PR solves: #611
Works in all browsers
👍
👍
can this be merged to DEV?
i would really like to have this feature
so useful !