mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 21:36:37 +02:00
✨ Add more DOM attrs friendly render-id generation hook
This commit is contained in:
parent
645b7e4b8d
commit
1b420e55f4
2 changed files with 9 additions and 1 deletions
|
@ -20,6 +20,13 @@
|
||||||
[goog.functions :as f]
|
[goog.functions :as f]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
(def ^:private render-id 0)
|
||||||
|
|
||||||
|
(defn use-render-id
|
||||||
|
"Get a stable, DOM usable identifier across all react rerenders"
|
||||||
|
[]
|
||||||
|
(mf/useMemo #(js* "\"render-\" + (++~{})" render-id) #js []))
|
||||||
|
|
||||||
(defn use-rxsub
|
(defn use-rxsub
|
||||||
[ob]
|
[ob]
|
||||||
(let [[state reset-state!] (mf/useState #(if (satisfies? IDeref ob) @ob nil))]
|
(let [[state reset-state!] (mf/useState #(if (satisfies? IDeref ob) @ob nil))]
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.ui.context :as muc]
|
[app.main.ui.context :as muc]
|
||||||
|
[app.main.ui.hooks :as h]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.export :as ed]
|
[app.main.ui.shapes.export :as ed]
|
||||||
[app.main.ui.shapes.fills :as fills]
|
[app.main.ui.shapes.fills :as fills]
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
(or (:blend-mode shape)))
|
(or (:blend-mode shape)))
|
||||||
|
|
||||||
type (dm/get-prop shape :type)
|
type (dm/get-prop shape :type)
|
||||||
render-id (mf/use-id)
|
render-id (h/use-render-id)
|
||||||
filter-id (dm/str "filter_" render-id)
|
filter-id (dm/str "filter_" render-id)
|
||||||
styles (-> (obj/create)
|
styles (-> (obj/create)
|
||||||
(obj/set! "pointerEvents" pointer-events)
|
(obj/set! "pointerEvents" pointer-events)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue