DEV Community


Posted on

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

Hello, guys. Glad to join the awesome 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 -

Top comments (1)

stereobooster profile image

The problem is that library has hardcoded dot as separator ('.', for example here, 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.