Fix incorrect usage of functional component (#17281)
Every keypress on an input field of the preview descriptor re-rendered the whole functional component and the input focus was lost. As we know from past issues, we should never use this pattern: (defn component [] [:f> (fn [] ...)])
This commit is contained in:
parent
baa9dff237
commit
dab4d953ec
|
@ -229,15 +229,12 @@
|
|||
style)}]
|
||||
children)])
|
||||
|
||||
|
||||
(defn preview-container
|
||||
(defn- f-preview-container
|
||||
[{:keys [state descriptor blur? blur-dark-only?
|
||||
component-container-style
|
||||
blur-container-style blur-view-props blur-height show-blur-background?]
|
||||
:or {blur-height 200}}
|
||||
& children]
|
||||
[:f>
|
||||
(fn []
|
||||
(rn/use-effect (fn []
|
||||
(when blur-dark-only?
|
||||
(if blur?
|
||||
|
@ -270,4 +267,8 @@
|
|||
blur-view-props)}]
|
||||
children)]
|
||||
(into [rn/view {:style (merge style/component-container component-container-style)}]
|
||||
children))]]])])
|
||||
children))]]])
|
||||
|
||||
(defn preview-container
|
||||
[& args]
|
||||
(into [:f> f-preview-container] args))
|
||||
|
|
Loading…
Reference in New Issue