瀏覽代碼

Update Filter.tsx

czhen 4 年之前
父節點
當前提交
1db08dc582
共有 1 個文件被更改,包括 4 次插入8 次删除
  1. 4 8
      client/src/components/advancedSearch/Filter.tsx

+ 4 - 8
client/src/components/advancedSearch/Filter.tsx

@@ -31,19 +31,15 @@ const Filter = function Filter(props: FilterProps) {
   const [isConditionsLegal, setIsConditionsLegal] = useState(false);
   const [isConditionsLegal, setIsConditionsLegal] = useState(false);
   const [filterExpression, setFilterExpression] = useState('');
   const [filterExpression, setFilterExpression] = useState('');
 
 
-  // useEffect(() => {
-  //   setInitConditions(flatConditions);
-  //   // eslint-disable-next-line react-hooks/exhaustive-deps
-  // }, []);
+  useEffect(() => {
+    setInitConditions(flatConditions);
+  // eslint-disable-next-line react-hooks/exhaustive-deps
+  }, []);
 
 
   // Check all conditions are all correct.
   // Check all conditions are all correct.
   useEffect(() => {
   useEffect(() => {
     // Calc the sum of conditions.
     // Calc the sum of conditions.
     setConditionSum(flatConditions.filter(i => i.type === 'condition').length);
     setConditionSum(flatConditions.filter(i => i.type === 'condition').length);
-    if (flatConditions.length === 0) {
-      setIsConditionsLegal(false);
-      return;
-    }
     for (let i = 0; i < flatConditions.length; i++) {
     for (let i = 0; i < flatConditions.length; i++) {
       const { data, type } = flatConditions[i];
       const { data, type } = flatConditions[i];
       if (type !== 'condition') continue;
       if (type !== 'condition') continue;