From 88b0aed79bd1e709bfdb984b1471e41b347f78ef Mon Sep 17 00:00:00 2001 From: David Sancho Date: Thu, 7 Mar 2024 13:14:32 +0100 Subject: [PATCH] Migrate to reason-react next version with React 18 (#28) * Install react/react-dom@18 * Migrate to new React.DOM.Client.createRoot/render API * Add pinning on Makefile install * fix build --------- Co-authored-by: Javier Chavarri --- src/ReactApp.re | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ReactApp.re b/src/ReactApp.re index ca49e7c..e09f7b9 100644 --- a/src/ReactApp.re +++ b/src/ReactApp.re @@ -9,12 +9,10 @@ module App = { ->React.array; }; -ReactDOM.querySelector("#root") -->( - fun - | Some(root) => ReactDOM.render(, root) - | None => - Js.Console.error( - "Failed to start React: couldn't find the #root element", - ) - ); +switch (ReactDOM.querySelector("#root")) { +| Some(element) => + let root = ReactDOM.Client.createRoot(element); + ReactDOM.Client.render(root, ); +| None => + Js.Console.error("Failed to start React: couldn't find the #root element") +};