diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-10 03:11:12 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-10 03:11:12 +0800 |
commit | 941448d65cc42870a93e0430158bfd7ab52fd2cd (patch) | |
tree | c5f4a1f00474b66e3479f5b38187aacb0dbf960c /packages/instant/src/components | |
parent | 764f402eb9bae2131a5eda52fd8d203f8e4bdecf (diff) | |
download | dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar.gz dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar.bz2 dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar.lz dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar.xz dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.tar.zst dexon-0x-contracts-941448d65cc42870a93e0430158bfd7ab52fd2cd.zip |
Fix empty input bug
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r-- | packages/instant/src/components/amount_input.tsx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 2b64469f6..29d1bf161 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -10,7 +10,7 @@ export interface AmountInputProps { fontColor?: ColorOption; fontSize?: string; value?: BigNumber; - onChange?: (value: BigNumber) => void; + onChange?: (value?: BigNumber) => void; } export class AmountInput extends React.Component<AmountInputProps> { @@ -22,7 +22,7 @@ export class AmountInput extends React.Component<AmountInputProps> { fontColor={fontColor} fontSize={fontSize} onChange={this._handleChange} - value={value ? value.toString() : undefined} + value={value ? value.toString() : ''} placeholder="0.00" width="2em" /> @@ -30,9 +30,13 @@ export class AmountInput extends React.Component<AmountInputProps> { ); } private readonly _handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => { - const bigNumberValue = new BigNumber(event.target.value); + const value = event.target.value; + let bigNumberValue; + if (!_.isEmpty(value)) { + bigNumberValue = new BigNumber(event.target.value); + } if (!_.isUndefined(this.props.onChange)) { this.props.onChange(bigNumberValue); } - } + }; } |