Browse Source

fix fetch partition

tumao 4 years ago
parent
commit
9f028ba865
1 changed files with 4 additions and 4 deletions
  1. 4 4
      client/src/components/insert/Container.tsx

+ 4 - 4
client/src/components/insert/Container.tsx

@@ -41,8 +41,8 @@ const InsertContainer: FC<InsertContentProps> = ({
   defaultSelectedCollection,
   defaultSelectedCollection,
   defaultSelectedPartition,
   defaultSelectedPartition,
 
 
-  partitions = [],
-  schema = [],
+  partitions,
+  schema,
   handleInsert,
   handleInsert,
 }) => {
 }) => {
   const classes = getStyles();
   const classes = getStyles();
@@ -127,7 +127,7 @@ const InsertContainer: FC<InsertContentProps> = ({
 
 
   useEffect(() => {
   useEffect(() => {
     // if not on partitions page, we need to fetch partitions according to selected collection
     // if not on partitions page, we need to fetch partitions according to selected collection
-    if (partitions.length === 0) {
+    if (!partitions || partitions.length === 0) {
       fetchPartition();
       fetchPartition();
     } else {
     } else {
       const options = partitions
       const options = partitions
@@ -203,7 +203,7 @@ const InsertContainer: FC<InsertContentProps> = ({
 
 
   const schemaOptions: Option[] = useMemo(() => {
   const schemaOptions: Option[] = useMemo(() => {
     const list =
     const list =
-      schema.length > 0
+      schema && schema.length > 0
         ? schema
         ? schema
         : collections.find(c => c._name === collectionValue)?._fields;
         : collections.find(c => c._name === collectionValue)?._fields;
     return (list || []).map(s => ({
     return (list || []).map(s => ({