diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-11 07:43:55 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-11 07:43:55 +0800 |
commit | 7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488 (patch) | |
tree | f1ee206d39d0bc5240235820713b851e98d98ccd | |
parent | 0a3c543d5d59f1fbc244fb796d6f9fb6826266a0 (diff) | |
download | dexon-0x-contracts-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.gz dexon-0x-contracts-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.zst dexon-0x-contracts-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.zip |
Fix issue where we throw if non-numeric characters are used in input
-rw-r--r-- | packages/instant/src/components/amount_input.tsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 29d1bf161..12cb9a48c 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -29,11 +29,16 @@ export class AmountInput extends React.Component<AmountInputProps> { </Container> ); } - private readonly _handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => { + private _handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => { const value = event.target.value; let bigNumberValue; if (!_.isEmpty(value)) { - bigNumberValue = new BigNumber(event.target.value); + try { + bigNumberValue = new BigNumber(event.target.value); + } catch { + // We don't want to allow values that can't be a BigNumber, so don't even call onChange. + return; + } } if (!_.isUndefined(this.props.onChange)) { this.props.onChange(bigNumberValue); |