Просмотр исходного кода

add if (typeof value === "string") {

visuddhinanda 2 лет назад
Родитель
Сommit
7bbc03f77a
1 измененных файлов с 9 добавлено и 7 удалено
  1. 9 7
      dashboard/src/components/dict/SelectCase.tsx

+ 9 - 7
dashboard/src/components/dict/SelectCase.tsx

@@ -8,7 +8,7 @@ interface CascaderOption {
   children?: CascaderOption[];
 }
 interface IWidget {
-  value?: string;
+  value?: string | null;
   onCaseChange?: Function;
 }
 const SelectCaseWidget = ({ value, onCaseChange }: IWidget) => {
@@ -16,12 +16,14 @@ const SelectCaseWidget = ({ value, onCaseChange }: IWidget) => {
   const [currValue, setCurrValue] = useState<(string | number)[]>();
 
   useEffect(() => {
-    const arrValue = value
-      ?.replaceAll("#", "$")
-      .replaceAll(":", ".$.")
-      .split("$")
-      .map((item) => item.replaceAll(".", ""));
-    setCurrValue(arrValue);
+    if (typeof value === "string") {
+      const arrValue = value
+        ?.replaceAll("#", "$")
+        .replaceAll(":", ".$.")
+        .split("$")
+        .map((item) => item.replaceAll(".", ""));
+      setCurrValue(arrValue);
+    }
   }, [value]);
 
   const case8 = [