aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2018-11-30 00:15:33 +0800
committerGitHub <noreply@github.com>2018-11-30 00:15:33 +0800
commitecc417069d4e0502052cc529d1d213916758b93a (patch)
treee5b27010914aeebb1606cd2fdb3ac1362f012020 /packages/instant/src
parent906bba7d751397afd507abf68fb7e0fb8ec7e31c (diff)
parent06b2f12b10c6c2030b326b3e817d497415862299 (diff)
downloaddexon-sol-tools-ecc417069d4e0502052cc529d1d213916758b93a.tar.gz
dexon-sol-tools-ecc417069d4e0502052cc529d1d213916758b93a.tar.zst
dexon-sol-tools-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/src')
-rw-r--r--packages/instant/src/components/erc20_token_selector.tsx8
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);