Skip to content

Commit

Permalink
Use react-create-class since React.createClass is deprecated
Browse files Browse the repository at this point in the history
Solves omcljs#881
  • Loading branch information
wilkerlucio authored and petterik committed Jul 20, 2017
1 parent c6f7d9b commit 9cb8287
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/main/om/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
9 changes: 8 additions & 1 deletion src/main/om/dom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9cb8287

Please sign in to comment.