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)}]
|
style)}]
|
||||||
children)])
|
children)])
|
||||||
|
|
||||||
|
(defn- f-preview-container
|
||||||
(defn preview-container
|
|
||||||
[{:keys [state descriptor blur? blur-dark-only?
|
[{:keys [state descriptor blur? blur-dark-only?
|
||||||
component-container-style
|
component-container-style
|
||||||
blur-container-style blur-view-props blur-height show-blur-background?]
|
blur-container-style blur-view-props blur-height show-blur-background?]
|
||||||
:or {blur-height 200}}
|
:or {blur-height 200}}
|
||||||
& children]
|
& children]
|
||||||
[:f>
|
|
||||||
(fn []
|
|
||||||
(rn/use-effect (fn []
|
(rn/use-effect (fn []
|
||||||
(when blur-dark-only?
|
(when blur-dark-only?
|
||||||
(if blur?
|
(if blur?
|
||||||
|
@ -270,4 +267,8 @@
|
||||||
blur-view-props)}]
|
blur-view-props)}]
|
||||||
children)]
|
children)]
|
||||||
(into [rn/view {:style (merge style/component-container component-container-style)}]
|
(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