Fix formatter (#7098)

The replace function can only work on a string, this little tweak will make the formatter not crash the page when the value is changed.
This commit is contained in:
tim-soft 2017-08-05 21:57:56 -06:00 committed by ddcat1115
parent 1651682020
commit fdb943e887

View File

@ -24,7 +24,7 @@ ReactDOM.render(
<div>
<InputNumber
defaultValue={1000}
formatter={value => `$ ${value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`}
formatter={value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
parser={value => value.replace(/\$\s?|(,*)/g, '')}
onChange={onChange}
/>