aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-11 07:43:55 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-11 07:43:55 +0800
commit7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488 (patch)
treef1ee206d39d0bc5240235820713b851e98d98ccd /packages/instant
parent0a3c543d5d59f1fbc244fb796d6f9fb6826266a0 (diff)
downloaddexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.gz
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.bz2
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.lz
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.xz
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.tar.zst
dexon-sol-tools-7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488.zip
Fix issue where we throw if non-numeric characters are used in input
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/amount_input.tsx9
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);