From 1ffca618f95eb48ce2366efa3c61112a268101e2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 12 Sep 2023 10:53:46 +0200 Subject: [PATCH] :bug: Fix react warning on incorrect hooks usage on shapes components --- frontend/src/app/main/ui/shapes/circle.cljs | 5 ++++- frontend/src/app/main/ui/shapes/frame.cljs | 4 ++-- frontend/src/app/main/ui/shapes/image.cljs | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/circle.cljs b/frontend/src/app/main/ui/shapes/circle.cljs index 50a947252b..a1cd362f36 100644 --- a/frontend/src/app/main/ui/shapes/circle.cljs +++ b/frontend/src/app/main/ui/shapes/circle.cljs @@ -8,6 +8,7 @@ (:require [app.common.data.macros :as dm] [app.common.geom.shapes :as gsh] + [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]] [app.util.object :as obj] @@ -30,8 +31,10 @@ rx (/ w 2) ry (/ h 2) + rid (mf/use-ctx muc/render-id) + props (mf/with-memo [shape] - (-> (attrs/extract-style-attrs shape) + (-> (attrs/extract-style-attrs shape rid) (obj/merge! #js {:cx cx :cy cy :rx rx :ry ry :transform t})))] [:& shape-custom-strokes {:shape shape} diff --git a/frontend/src/app/main/ui/shapes/frame.cljs b/frontend/src/app/main/ui/shapes/frame.cljs index e0c31dc614..2ad080c4fe 100644 --- a/frontend/src/app/main/ui/shapes/frame.cljs +++ b/frontend/src/app/main/ui/shapes/frame.cljs @@ -42,8 +42,8 @@ h (dm/get-prop shape :height) t (gsh/transform-str shape) - props (mf/with-memo [shape] - (-> (attrs/extract-style-attrs shape) + props (mf/with-memo [shape render-id] + (-> (attrs/extract-style-attrs shape render-id) (obj/merge! #js {:x x :y y :width w :height h :transform t}))) path? (some? (.-d props))] diff --git a/frontend/src/app/main/ui/shapes/image.cljs b/frontend/src/app/main/ui/shapes/image.cljs index 42b9ddc5ab..cb201846ce 100644 --- a/frontend/src/app/main/ui/shapes/image.cljs +++ b/frontend/src/app/main/ui/shapes/image.cljs @@ -7,6 +7,7 @@ (ns app.main.ui.shapes.image (:require [app.common.geom.shapes :as gsh] + [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]] [app.util.object :as obj] @@ -18,8 +19,10 @@ (let [shape (unchecked-get props "shape") {:keys [x y width height]} shape + + render-id (mf/use-ctx muc/render-id) transform (gsh/transform-str shape) - props (-> (attrs/extract-style-attrs shape) + props (-> (attrs/extract-style-attrs shape render-id) (obj/merge! (attrs/extract-border-radius-attrs shape)) (obj/merge! #js {:x x