diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-02 04:37:43 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-02 04:38:12 +0800 |
commit | 0a3af4eb224d68cfe1b3e16b912549cb52e5d0a5 (patch) | |
tree | 959e9db6ab67a936004b715218258ab922a3b4d3 | |
parent | 7fc1a88680e85c5ab1a1ef7ba5eb1bc223614493 (diff) | |
download | dexon-sol-tools-0a3af4eb224d68cfe1b3e16b912549cb52e5d0a5.tar.gz dexon-sol-tools-0a3af4eb224d68cfe1b3e16b912549cb52e5d0a5.tar.zst dexon-sol-tools-0a3af4eb224d68cfe1b3e16b912549cb52e5d0a5.zip |
chore: add clarification to _generateSelectAssetClickHandler
-rw-r--r-- | packages/instant/src/components/erc20_asset_amount_input.tsx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/instant/src/components/erc20_asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx index 05b81e93d..56f892328 100644 --- a/packages/instant/src/components/erc20_asset_amount_input.tsx +++ b/packages/instant/src/components/erc20_asset_amount_input.tsx @@ -122,18 +122,19 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput currentFontSizePx: fontSizePx, }); }; - // We don't want to allow opening the token selection panel if there are no assets. private readonly _generateSelectAssetClickHandler = (): (() => void) | undefined => { - const { numberOfAssetsAvailable } = this.props; - if (_.isUndefined(numberOfAssetsAvailable) || numberOfAssetsAvailable <= 1) { + // We don't want to allow opening the token selection panel if there are no assets. + // Since styles are inferred from the presence of a click handler, we want to return undefined + // instead of providing a noop. + const { numberOfAssetsAvailable, onSelectAssetClick } = this.props; + if ( + _.isUndefined(numberOfAssetsAvailable) || + numberOfAssetsAvailable <= 1 || + _.isUndefined(onSelectAssetClick) + ) { return undefined; } - return this._handleSelectAssetClick; - }; - private readonly _handleSelectAssetClick = () => { - if (this.props.onSelectAssetClick) { - this.props.onSelectAssetClick(this.props.asset); - } + return () => onSelectAssetClick(this.props.asset); }; // For assets with symbols of different length, // start scaling the input at different character lengths |