From 9cb82870ea82b3b76ea0a9d54df2bbaf2d97689a Mon Sep 17 00:00:00 2001 From: Wilker Lucio Date: Wed, 19 Jul 2017 19:17:12 -0300 Subject: [PATCH] Use react-create-class since React.createClass is deprecated Solves #881 --- build.boot | 1 + project.clj | 1 + src/main/om/core.cljs | 2 +- src/main/om/dom.cljs | 9 ++++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build.boot b/build.boot index 42871cbc..6c21ac49 100644 --- a/build.boot +++ b/build.boot @@ -13,6 +13,7 @@ [cljsjs/react "15.3.1-0"] [cljsjs/react-dom "15.3.1-0"] [com.cognitect/transit-clj "0.8.297"] + [cljsjs/create-react-class "15.6.0-0"] [com.cognitect/transit-cljs "0.8.239"] [org.clojure/core.async "0.2.395" :scope "test" diff --git a/project.clj b/project.clj index f19fc38a..84245750 100644 --- a/project.clj +++ b/project.clj @@ -18,6 +18,7 @@ [cljsjs/react "15.3.1-0"] [cljsjs/react-dom "15.3.1-0"] [com.cognitect/transit-clj "0.8.290"] + [cljsjs/create-react-class "15.6.0-0"] [com.cognitect/transit-cljs "0.8.239"] [org.clojure/core.async "0.2.385" :scope "test" diff --git a/src/main/om/core.cljs b/src/main/om/core.cljs index 3accfb07..d8248098 100644 --- a/src/main/om/core.cljs +++ b/src/main/om/core.cljs @@ -900,7 +900,7 @@ (let [rdesc (or descriptor *descriptor* pure-descriptor)] (when (or (nil? (gobj/get f "om$descriptor")) (not (identical? rdesc (gobj/get f "om$tag")))) - (let [factory (js/React.createFactory (js/React.createClass rdesc))] + (let [factory (js/React.createFactory (dom/create-class rdesc))] (gobj/set f "om$descriptor" factory) (gobj/set f "om$tag" rdesc)))) (gobj/get f "om$descriptor"))) diff --git a/src/main/om/dom.cljs b/src/main/om/dom.cljs index 9e597c32..695e10fe 100644 --- a/src/main/om/dom.cljs +++ b/src/main/om/dom.cljs @@ -3,14 +3,21 @@ (:require-macros [om.dom :as dom]) (:require [cljsjs.react] [cljsjs.react.dom] + [cljsjs.create-react-class] [om.util :as util] [goog.object :as gobj])) +(defonce create-class + (cond (exists? js/createReactClass) js/createReactClass + (exists? js/require) (or (js/require "create-react-class") + (throw (js/Error. "require('create-react-class') failed"))) + :else (throw (js/Error. "js/createReactClass is missing")))) + (dom/gen-react-dom-fns) (defn wrap-form-element [ctor display-name] (js/React.createFactory - (js/React.createClass + (create-class #js {:getDisplayName (fn [] display-name)