Skip to content

Commit

Permalink
Show icon on component render
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Jul 16, 2024
1 parent 4f2d479 commit 33df005
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions fabric/src/components/TextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,31 @@ export function AddressInput({
errorMessage,
onBlur,
onChange,
value,
value = '',
clearIcon,
...inputProps
}: AddressInputProps) {
const defaultId = React.useId()
id ??= defaultId

const [inputVal, setInputVal] = React.useState<string>(value)
const [network, setNetwork] = React.useState<'ethereum' | 'centrifuge' | 'loading' | null>(null)

function handleChange(e: React.FocusEvent<HTMLInputElement>) {
const address = e.target.value
if (isEvmAddress(address) && address.length > 3) {
React.useEffect(() => {
if (isEvmAddress(inputVal) && inputVal.length > 3) {
setNetwork('ethereum')
} else if (isSubstrateAddress(address) && address.length > 3) {
} else if (isSubstrateAddress(inputVal) && inputVal.length > 3) {
setNetwork('centrifuge')
} else if (address !== '') {
} else if (inputVal !== '') {
setNetwork('loading')
} else {
setNetwork(null)
}
}, [inputVal])

function handleChange(e: React.FocusEvent<HTMLInputElement>) {
const address = e.target.value
setInputVal(address)
if (onChange) {
onChange(e)
}
Expand Down

0 comments on commit 33df005

Please sign in to comment.