Upgrading to 1.2

Reagent 1.2 adds optional, experimental support for React 18. Upgrading doesn't require any changes: reagent.dom/render keeps using the old ReactDOM.render API, so you can continue using React 17 like before.

Using React 18

To use the React 18 createRoot API, use the new reagent.dom.client namespace:

(ns example.core
  (:require [reagent.dom.client :as rdomc]))

(defonce root (rdomc/create-root (js/document.getElementById "app")))

(defn init []
  (rdomc/render root [app]))

With createRoot, React batches updates differently, see React 19 and Reagent for how this affects Reagent.

You can also keep using reagent.dom/render with React 18. React then runs in the compatibility mode (i.e., not using createRoot / concurrent mode), which is how Reagent 1 is tested against React 18.

Cljsjs

When using React 18 or older you can provide the react dependencies using Cljsjs React packages to your project:

[cljsjs/react "18.3.1-1"]
[cljsjs/react-dom "18.3.1-1"]

Deprecations

  • reagent.dom/dom-node and reagent.dom/force-update-all are deprecated.