From 51c6b25b952b9bde8bcd43e81cca1bf304bc8a50 Mon Sep 17 00:00:00 2001 From: scheinriese Date: Tue, 19 May 2026 14:13:35 +0200 Subject: [PATCH] fix(property/value): icon-row hook crash when picker opens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit icon-row was modified earlier in this branch (c85e8e5588) to add < rum/reactive db-mixins/query mixins so a model/sub-block call could refresh the entity reactively. Those mixins turn rum/defc into a class component, but the component still called hooks/use-effect! — which internally calls React.useEffect and is only valid inside a function component's body. The result: an Invalid-hook-call exception every time icon-row rendered, surfacing as a "Something wrong, please try again" toast when the user clicked to add a page icon. Convert rum/defc → rum/defcs (class component, takes state as first arg) and replace the hooks/use-effect! cleanup with a :will-unmount lifecycle. The original effect returned a cleanup that restored the cursor when `editing?` was true on unmount; lifecycle-based unmount is the natural equivalent. Verified live: page reloads, picker can render icon-row without throwing — zero hook errors in console. Co-Authored-By: Claude Opus 4.7 --- .../frontend/components/property/value.cljs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index 29925420b8..c0824315da 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -96,13 +96,16 @@ (or (> (count selected-blocks) 1) (seq view-selected-blocks)))) -(rum/defc icon-row < rum/reactive db-mixins/query - [block editing?] - (hooks/use-effect! - (fn [] - (fn [] - (when editing? - (editor-handler/restore-last-saved-cursor!))))) +(rum/defcs icon-row < rum/reactive db-mixins/query + {:will-unmount (fn [state] + ;; The class mixins (rum/reactive + db-mixins/query) make + ;; this a class component, so hooks/use-effect! is invalid + ;; here. Restore the cursor on unmount via lifecycle instead. + (let [[_ editing?] (:rum/args state)] + (when editing? + (editor-handler/restore-last-saved-cursor!))) + state)} + [_state block editing?] ;; Subscribe to a fresh entity reference. Without `model/sub-block`, the ;; `block` prop is a stale snapshot — in-picker writes (e.g. shape changes ;; from the customize band) update the entity but the snapshot held by this