Kaynağa Gözat

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

visuddhinanda 2 yıl önce
ebeveyn
işleme
7bbc03f77a
1 değiştirilmiş dosya ile 9 ekleme ve 7 silme
  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 = [