diff options
author | Steve Klebanoff <steve@0xproject.com> | 2018-11-30 00:15:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-30 00:15:33 +0800 |
commit | ecc417069d4e0502052cc529d1d213916758b93a (patch) | |
tree | e5b27010914aeebb1606cd2fdb3ac1362f012020 /packages/instant | |
parent | 906bba7d751397afd507abf68fb7e0fb8ec7e31c (diff) | |
parent | 06b2f12b10c6c2030b326b3e817d497415862299 (diff) | |
download | dexon-0x-contracts-ecc417069d4e0502052cc529d1d213916758b93a.tar.gz dexon-0x-contracts-ecc417069d4e0502052cc529d1d213916758b93a.tar.zst dexon-0x-contracts-ecc417069d4e0502052cc529d1d213916758b93a.zip |
Merge pull request #1347 from 0xProject/fix/instant/input-react-warning
[instant] Fix uncontrolled input warning for token selector
Diffstat (limited to 'packages/instant')
-rw-r--r-- | packages/instant/src/components/erc20_token_selector.tsx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/instant/src/components/erc20_token_selector.tsx b/packages/instant/src/components/erc20_token_selector.tsx index 0a3d4427a..f7d5a4fe4 100644 --- a/packages/instant/src/components/erc20_token_selector.tsx +++ b/packages/instant/src/components/erc20_token_selector.tsx @@ -19,12 +19,12 @@ export interface ERC20TokenSelectorProps { } export interface ERC20TokenSelectorState { - searchQuery?: string; + searchQuery: string; } export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps> { public state: ERC20TokenSelectorState = { - searchQuery: undefined, + searchQuery: '', }; public render(): React.ReactNode { const { tokens, onTokenSelect } = this.props; @@ -62,10 +62,10 @@ export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps> }; private readonly _isTokenQueryMatch = (token: ERC20Asset): boolean => { const { searchQuery } = this.state; - if (_.isUndefined(searchQuery)) { + const searchQueryLowerCase = searchQuery.toLowerCase().trim(); + if (searchQueryLowerCase === '') { return true; } - const searchQueryLowerCase = searchQuery.toLowerCase(); const tokenName = token.metaData.name.toLowerCase(); const tokenSymbol = token.metaData.symbol.toLowerCase(); return _.startsWith(tokenSymbol, searchQueryLowerCase) || _.startsWith(tokenName, searchQueryLowerCase); |