diff --git a/packages/app-explorer/src/Query.tsx b/packages/app-explorer/src/Query.tsx index 7efcc5bb48..9333f8789d 100644 --- a/packages/app-explorer/src/Query.tsx +++ b/packages/app-explorer/src/Query.tsx @@ -4,9 +4,9 @@ import { I18nProps } from '@polkadot/react-components/types'; -import React from 'react'; +import React, { useState } from 'react'; import styled from 'styled-components'; -import { Button, FilterOverlay, Input, TxComponent } from '@polkadot/react-components'; +import { Button, FilterOverlay, Input } from '@polkadot/react-components'; import { isHex } from '@polkadot/util'; import translate from './translate'; @@ -17,68 +17,47 @@ interface Props extends I18nProps { interface State { value: string; - isNumber: boolean; isValid: boolean; } -class Query extends TxComponent { - public constructor (props: Props) { - super(props); +function stateFromValue (value: string): State { + const isValidHex = isHex(value, 256); + const isNumber = !isValidHex && /^\d+$/.test(value); - const { value } = this.props; + return { + value, + isValid: isValidHex || isNumber + }; +} - this.state = this.stateFromValue(value || ''); - } - - public render (): React.ReactNode { - const { className, t } = this.props; - const { value, isValid } = this.state; - - return ( - - -