Repository: penpot/penpot
File: frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs (ClojureScript)

Code before:
                           (cfv/extract-properties-values data objects variant-id))

        get-options
        (mf/use-fn
         (mf/deps prop-vals)
         (fn [prop-name]
           (get-variant-options prop-name prop-vals)))

        select-duplicated-comps
        (mf/use-fn
         (mf/deps duplicated-comps)
         #(let [ids (map :id duplicated-comps)]
            (if (= current-file-id (:component-file shape))
              (st/emit! (dwl/go-to-local-component {:id (first ids)
                                                    :additional-ids (rest ids)}))
              (st/emit! (dwl/go-to-component-file (:component-file shape)
                                                  (first duplicated-comps))))))

        select-malformed-comps
        (mf/use-fn
         (mf/deps current-file-id shape component component-id)
         (fn []
           (let [ids (map :id malformed-comps)]
             (if (= current-file-id (:component-file shape))
               (st/emit! (dwl/go-to-local-component :id (first ids) :additional-ids (rest ids)))
               (st/emit! (dwl/go-to-component-file (:component-file shape) (first malformed-comps)))))))

        switch-component
        (mf/use-fn
         (mf/deps shape)
         (fn [pos val]
           (when (not= val (dm/get-in component [:variant-properties pos :value]))
             (let [target-props (-> (:variant-properties component)
                                    (update pos assoc :value val))
                   valid-comps  (->> variant-comps
                                     (remove #(= (:id %) component-id))
                                     (filter #(= (dm/get-in % [:variant-properties pos :value]) val))
                                     (reverse))
                   nearest-comp (apply min-key #(ctv/distance target-props (:variant-properties %)) valid-comps)]
               (when nearest-comp
                 (st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]

    [:*
     [:div {:class (stl/css :variant-property-list)}
      (for [[pos prop] (map vector (range) properties)]
        [:div {:key (str (:id shape) pos) :class (stl/css :variant-property-container)}
         [:*
          [:span {:class (stl/css :variant-property-name)}
           (:name prop)]
          [:> select* {:default-selected (:value prop)
                       :options (get-options (:name prop))

Review comment (suggestion):
`malformed-comps` missing in deps

Also, putting it on deps as-is will invalidate the use of `mf/use-fn` because `malformced-comps`  has no `with-memo`  so it will be different in each rerender. So I suggest  putting it into with-memo also.

Code after:
                                              :variant-error))))

        prop-vals        (mf/with-memo [data objects variant-id]
                           (cfv/extract-properties-values data objects variant-id))

        get-options
        (mf/use-fn
         (mf/deps prop-vals)
         (fn [prop-name]
           (get-variant-options prop-name prop-vals)))

        select-duplicated-comps
        (mf/use-fn
         (mf/deps current-file-id shape duplicated-comps)
         #(let [ids (map :id duplicated-comps)]
            (if (= current-file-id (:component-file shape))
              (st/emit! (dwl/go-to-local-component {:id (first ids)
                                                    :additional-ids (rest ids)}))
              (st/emit! (dwl/go-to-component-file (:component-file shape)
                                                  (first duplicated-comps))))))

        select-malformed-comps
        (mf/use-fn
         (mf/deps current-file-id shape malformed-comps)
         (fn []
           (let [ids (map :id malformed-comps)]
             (if (= current-file-id (:component-file shape))
               (st/emit! (dwl/go-to-local-component :id (first ids) :additional-ids (rest ids)))
               (st/emit! (dwl/go-to-component-file (:component-file shape) (first malformed-comps)))))))

        switch-component
        (mf/use-fn
         (mf/deps shape component component-id variant-comps)
         (fn [pos val]
           (when (not= val (dm/get-in component [:variant-properties pos :value]))
             (let [target-props (-> (:variant-properties component)
                                    (update pos assoc :value val))
                   valid-comps  (->> variant-comps
                                     (remove #(= (:id %) component-id))
                                     (filter #(= (dm/get-in % [:variant-properties pos :value]) val))
                                     (reverse))
                   nearest-comp (apply min-key #(ctv/distance target-props (:variant-properties %)) valid-comps)]
               (when nearest-comp
                 (st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]

    [:*
     [:div {:class (stl/css :variant-property-list)}
      (for [[pos prop] (map vector (range) properties)]
        [:div {:key (str (:id shape) pos) :class (stl/css :variant-property-container)}
         [:*
          [:span {:class (stl/css :variant-property-name)}