DEV Community

DeylEnergy
DeylEnergy

Posted on

How to win the fight against react-number-format's keyDown handler?

Hello, guys. Glad to join the awesome DEV.to community. I'm banging my head on the keyboard trying to understand how to make react-number-format library to treat keyDown event where key property ',' (comma) as if a user typed '.' (period).

It perfectly works with the first example where decimalSeparator=',' In this case, the component takes '.' as if a user typed ','. I want the same effect, but for the second example, so the library could get ',' as if a user typed '.'.

Already tried to curb through the code, but unfortunately, debugger behaves oddly in Chrome DevTools. Would be glad if anybody gives the notion where to move in order to make it happen. Thanks.

Codesandbox - https://codesandbox.io/s/recursing-sky-23o31

Top comments (1)

Collapse
 
stereobooster profile image
stereobooster

The problem is that library has hardcoded dot as separator ('.', for example here github.com/s-yadav/react-number-fo..., but in other places as well). As far as I can tell the fact that first example of <NumberFormat works as you described is rather a bug than a feature.