浏览代码

search-input runtime-error fix

daviddeepan 1 年之前
父节点
当前提交
09c07e58e6
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      web/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx

+ 5 - 2
web/apps/photos/src/components/Search/SearchBar/searchInput/index.tsx

@@ -56,8 +56,11 @@ export default function SearchInput(props: Iprops) {
     const [value, setValue] = useState<SearchOption>(null);
     const appContext = useContext(AppContext);
     const handleChange = (value: SearchOption) => {
-        setValue(value);
-        setQuery(value.label);
+        if (value) {
+            setValue(value);
+            setQuery(value.label);
+        }
+
         blur();
     };
     const handleInputChange = (value: string, actionMeta: InputActionMeta) => {