Don't create keys seq on each rerender on token-pill component

This commit is contained in:
Andrey Antukh 2025-02-04 16:57:11 +01:00
parent 5575a66b8d
commit bccc90f5a2

View file

@ -138,9 +138,9 @@
;; we don't need to perform this regex operation on each rerender
(defn contains-reference-value?
"Extracts the value between `{}` in a string and checks if it's in the provided vector."
[text values]
[text active-tokens]
(let [match (second (re-find #"\{([^}]+)\}" text))]
(boolean (some #(= % match) values))))
(contains? active-tokens match)))
(mf/defc token-pill
{::mf/wrap-props false}
@ -156,7 +156,7 @@
is-viewer (not can-edit?)
ref-not-in-active-set (and is-reference?
(not (contains-reference-value? value (keys active-theme-tokens))))
(not (contains-reference-value? value active-theme-tokens)))
no-valid-value (seq errors)
errors? (or ref-not-in-active-set