浏览代码

chore(dev): react keys warnings

charlie 10 月之前
父节点
当前提交
91f3dc3d41
共有 2 个文件被更改,包括 13 次插入11 次删除
  1. 12 10
      deps/shui/src/logseq/shui/shortcut/v1.cljs
  2. 1 1
      src/main/frontend/components/dnd.cljs

+ 12 - 10
deps/shui/src/logseq/shui/shortcut/v1.cljs

@@ -62,26 +62,28 @@
                                      "bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
                        :size size}
                       (for [[index tile] (map-indexed vector tiles)]
-                        [:<>
-                         (when (< 0 index)
-                           [:span.ui__button__tile-separator])
-                         [:span.ui__button__tile tile]]))))
+                        [:span {:key index}
+                         [:<>
+                          (when (< 0 index)
+                            [:span.ui__button__tile-separator])
+                          [:span.ui__button__tile tile]]]))))
 
 (rum/defc root
   [shortcut & {:keys [size theme interactive?]
-               :or   {size  :xs
-                      interactive? true
-                      theme :gray}}]
+               :or {size :xs
+                    interactive? true
+                    theme :gray}}]
   (when (seq shortcut)
     (let [shortcuts (if (coll? shortcut)
                       [shortcut]
                       (parse-shortcuts shortcut))
           opts {:interactive? interactive?}]
       (for [[index binding] (map-indexed vector shortcuts)]
-        [:<>
+        [:span
+         {:key (str index)}
          (when (< 0 index)
-           [:div.text-gray-11.text-sm {:key "sep"} "|"])
-         (if (coll? (first binding))   ; + included
+           [:span.text-gray-11.text-sm {:key "sep"} "|"])
+         (if (coll? (first binding))                        ; + included
            (for [[idx ks] (map-indexed vector binding)]
              (rum/with-key
                (part ks size opts)

+ 1 - 1
src/main/frontend/components/dnd.cljs

@@ -94,7 +94,7 @@
                        :else
                        (rum/with-key (sortable-item prop (:content item)) id))))
         children' (if parent-node
-                    [parent-node children]
+                    [parent-node {:key "parent-node"} children]
                     children)]
     (dnd-context
      dnd-opts