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*
|
||||
[{:keys [values on-change on-blur]}]
|
||||
(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
|
||||
(mf/use-fn
|
||||
(mf/deps on-change on-blur direction)
|
||||
@ -94,14 +105,7 @@
|
||||
[:> radio-buttons* {:selected direction
|
||||
:on-change handle-change
|
||||
:name "text-direction-options"
|
||||
:options [{: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}]}]]))
|
||||
:options options}]]))
|
||||
|
||||
(mf/defc vertical-align*
|
||||
[{:keys [values on-change on-blur]}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user