From e730e9ee646bd50882b0421a146fa02ff5cc5e92 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 17 Mar 2026 10:06:16 +0100 Subject: [PATCH] :bug: Fix subscribe to undefined stream error in use-stream hook (#8633) Add a nil guard before subscribing to the stream in the use-stream hook. When a nil/undefined stream is passed (e.g., from a conditional expression or timing edge case during React rendering), the subscribe call on undefined causes a TypeError. The guard ensures we only subscribe when the stream is defined. Signed-off-by: Andrey Antukh --- frontend/src/app/main/ui/hooks.cljs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/hooks.cljs b/frontend/src/app/main/ui/hooks.cljs index a7ba644c8c..b4ad8fe616 100644 --- a/frontend/src/app/main/ui/hooks.cljs +++ b/frontend/src/app/main/ui/hooks.cljs @@ -214,10 +214,11 @@ (mf/use-effect deps (fn [] - (let [sub (->> stream (rx/subs! on-subscribe))] - #(do - (rx/dispose! sub) - (when on-dispose (on-dispose)))))))) + (when stream + (let [sub (->> stream (rx/subs! on-subscribe))] + #(do + (rx/dispose! sub) + (when on-dispose (on-dispose))))))))) ;; https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state ;; FIXME: replace with rumext