From 5aff49450a302e592b9c4bc15e3237dcc1bb5691 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Fri, 15 Nov 2024 13:21:44 +0200 Subject: [PATCH] Enable React 18 mode for tests --- test/reagenttest/utils.cljs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/reagenttest/utils.cljs b/test/reagenttest/utils.cljs index d7dac479..ef01dc2b 100644 --- a/test/reagenttest/utils.cljs +++ b/test/reagenttest/utils.cljs @@ -4,6 +4,7 @@ [reagent.core :as r] [reagent.dom :as rdom] [reagent.dom.server :as server] + [reagent.dom.client :as rdomc] [reagent.debug :as debug] [reagent.impl.template :as tmpl])) @@ -36,24 +37,26 @@ ([comp f] (with-mounted-component comp *test-compiler* f)) ([comp compiler f] - (let [div (.createElement js/document "div")] + (let [div (.createElement js/document "div") + root (rdomc/create-root div)] (try (let [c (if compiler - (rdom/render comp div compiler) - (rdom/render comp div))] + (rdomc/render root comp compiler) + (rdomc/render root comp))] (f c div)) (finally - (rdom/unmount-component-at-node div) + (.unmount root) (r/flush)))))) (defn with-mounted-component-async [comp done compiler f] (let [div (.createElement js/document "div") + root (rdomc/create-root div) c (if compiler - (rdom/render comp div compiler) - (rdom/render comp div))] + (rdomc/render root comp compiler) + (rdomc/render root comp))] (f c div (fn [] - (rdom/unmount-component-at-node div) + (.unmount root) (r/flush) (done)))))