mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
⚡ Memoize static options in text-direction-options* component
Wrap the two radio-button option maps in mf/with-memo [] so the vector and its (tr ...) calls are evaluated once per mount instead of on every render. Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
466f27eb7c
commit
dfd992aa49
@ -83,6 +83,17 @@
|
|||||||
(mf/defc text-direction-options*
|
(mf/defc text-direction-options*
|
||||||
[{:keys [values on-change on-blur]}]
|
[{:keys [values on-change on-blur]}]
|
||||||
(let [direction (:text-direction values)
|
(let [direction (:text-direction values)
|
||||||
|
options
|
||||||
|
(mf/with-memo []
|
||||||
|
[{:value "ltr"
|
||||||
|
:id "ltr-text-direction"
|
||||||
|
:label (tr "workspace.options.text-options.direction-ltr")
|
||||||
|
:icon i/text-ltr}
|
||||||
|
{:value "rtl"
|
||||||
|
:id "rtl-text-direction"
|
||||||
|
:label (tr "workspace.options.text-options.direction-rtl")
|
||||||
|
:icon i/text-rtl}])
|
||||||
|
|
||||||
handle-change
|
handle-change
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps on-change on-blur direction)
|
(mf/deps on-change on-blur direction)
|
||||||
@ -94,14 +105,7 @@
|
|||||||
[:> radio-buttons* {:selected direction
|
[:> radio-buttons* {:selected direction
|
||||||
:on-change handle-change
|
:on-change handle-change
|
||||||
:name "text-direction-options"
|
:name "text-direction-options"
|
||||||
:options [{:value "ltr"
|
:options options}]]))
|
||||||
:id "ltr-text-direction"
|
|
||||||
:label (tr "workspace.options.text-options.direction-ltr")
|
|
||||||
:icon i/text-ltr}
|
|
||||||
{:value "rtl"
|
|
||||||
:id "rtl-text-direction"
|
|
||||||
:label (tr "workspace.options.text-options.direction-rtl")
|
|
||||||
:icon i/text-rtl}]}]]))
|
|
||||||
|
|
||||||
(mf/defc vertical-align*
|
(mf/defc vertical-align*
|
||||||
[{:keys [values on-change on-blur]}]
|
[{:keys [values on-change on-blur]}]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user