From 9f2e5bbe94b54d258f19d539ff36b7068b52ce58 Mon Sep 17 00:00:00 2001 From: Ky Lee Date: Thu, 13 Jun 2024 17:11:46 -0700 Subject: [PATCH] fix: token components lint errors --- src/token/components/SearchIcon.tsx | 2 ++ src/token/components/TextInput.tsx | 14 ++++++++++---- src/token/components/TokenChip.tsx | 6 ++++-- src/token/components/TokenImage.tsx | 3 ++- src/token/components/TokenRow.tsx | 1 + src/token/components/TokenSearch.tsx | 19 +++++++++++-------- src/token/components/TokenSelectButton.tsx | 5 +++++ src/token/components/TokenSelectDropdown.tsx | 2 +- 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/token/components/SearchIcon.tsx b/src/token/components/SearchIcon.tsx index 08cd0b64c8..9c0d23eb44 100644 --- a/src/token/components/SearchIcon.tsx +++ b/src/token/components/SearchIcon.tsx @@ -1,6 +1,8 @@ export function SearchIcon() { return ( ) => { - onChange(evt.target.value); - }, []); + const handleChange = useCallback( + (evt: ChangeEvent) => { + onChange(evt.target.value); + }, + [onChange], + ); const handleClear = useCallback(() => { onChange(''); - }, []); + }, [onChange]); return (
@@ -31,11 +34,14 @@ export function TextInput({ placeholder, value, onChange }: TextInputReact) { /> {value && ( ); diff --git a/src/token/components/TokenImage.tsx b/src/token/components/TokenImage.tsx index 8291036a73..21f203f1a2 100644 --- a/src/token/components/TokenImage.tsx +++ b/src/token/components/TokenImage.tsx @@ -18,7 +18,7 @@ export function TokenImage({ className, size = 24, token }: TokenImageReact) { height: `${size}px`, }, }; - }, [size]); + }, [size, name]); if (!image) { return ( @@ -35,6 +35,7 @@ export function TokenImage({ className, size = 24, token }: TokenImageReact) { return ( token-image onClick?.(token)} > diff --git a/src/token/components/TokenSearch.tsx b/src/token/components/TokenSearch.tsx index 110b84f93f..e735fcae0b 100644 --- a/src/token/components/TokenSearch.tsx +++ b/src/token/components/TokenSearch.tsx @@ -10,15 +10,18 @@ export function TokenSearch({ onChange, delayMs = 200 }: TokenSearchReact) { onChange(value); }, delayMs); - const handleChange = useCallback((value: string) => { - setValue(value); + const handleChange = useCallback( + (value: string) => { + setValue(value); - if (delayMs > 0) { - handleDebounce(value); - } else { - onChange(value); - } - }, []); + if (delayMs > 0) { + handleDebounce(value); + } else { + onChange(value); + } + }, + [onChange, handleDebounce, delayMs], + ); return ( { document.removeEventListener('click', handleBlur); }; - }, []); + }, [handleBlur]); return (