s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.9k stars 410 forks source link

Package should not throw errors when `thousandSeparator` and `decimalSeparator` are similar #831

Open ralucaStan opened 8 months ago

ralucaStan commented 8 months ago

Describe the issue and the actual behavior

When thousandSeparator and decimalSeparator are similar, the plugin throws an Error.

Describe the expected behavior

Although those separators should not be identical I don't think react-number-format should throw an error. IMO it should show an warning informing the developers and it should still render some output; Informing developers allows them to see and fix the issue upstream. Renderign a value would enable consumers of the plugin to not provide a broken experience. Throwing an error is impacting flows on real websites. Imagine a checkout flow interrupted by a formatting plugin.

Provide a CodeSandbox link illustrating the issue

Not needed

<NumberFormat
  thousandSeparator="."
  decimalSeparator="."
  ... 
  />

Nice to have

Communicate this limitation in the docs