mirror of https://github.com/status-im/reagent.git
Make components look nicer in React's Chrome plugin
This commit is contained in:
parent
969b63cd00
commit
c23bb970e7
|
@ -83,11 +83,13 @@
|
||||||
c2 (aget nextprops cljs-children)]
|
c2 (aget nextprops cljs-children)]
|
||||||
(not (util/equal-args p1 c1 p2 c2))))
|
(not (util/equal-args p1 c1 p2 c2))))
|
||||||
|
|
||||||
(defn wrap-component [comp extras]
|
(defn wrap-component [comp extras name]
|
||||||
(.createClass React (js-obj "render"
|
(.createClass React (js-obj "render"
|
||||||
#(this-as C (wrapped-render C comp extras))
|
#(this-as C (wrapped-render C comp extras))
|
||||||
"shouldComponentUpdate"
|
"shouldComponentUpdate"
|
||||||
#(this-as C (wrapped-should-update C %1 %2)))))
|
#(this-as C (wrapped-should-update C %1 %2))
|
||||||
|
"displayName"
|
||||||
|
(or name "ComponentWrapper"))))
|
||||||
|
|
||||||
;; From Weavejester's Hiccup, via pump:
|
;; From Weavejester's Hiccup, via pump:
|
||||||
(def ^{:doc "Regular expression that parses a CSS-style id and class
|
(def ^{:doc "Regular expression that parses a CSS-style id and class
|
||||||
|
@ -107,7 +109,7 @@
|
||||||
|
|
||||||
(defn get-wrapper [tag]
|
(defn get-wrapper [tag]
|
||||||
(let [[comp id-class] (parse-tag tag)]
|
(let [[comp id-class] (parse-tag tag)]
|
||||||
(wrap-component comp id-class)))
|
(wrap-component comp id-class (str tag))))
|
||||||
|
|
||||||
(def cached-wrapper (memoize get-wrapper))
|
(def cached-wrapper (memoize get-wrapper))
|
||||||
|
|
||||||
|
@ -128,7 +130,7 @@
|
||||||
(if-not (nil? cached-class)
|
(if-not (nil? cached-class)
|
||||||
cached-class
|
cached-class
|
||||||
(if (.isValidClass React tag)
|
(if (.isValidClass React tag)
|
||||||
(set! (.-cljsReactClass tag) (wrap-component tag nil))
|
(set! (.-cljsReactClass tag) (wrap-component tag nil nil))
|
||||||
(fn-to-class tag)))))))
|
(fn-to-class tag)))))))
|
||||||
|
|
||||||
(defn vec-to-comp [v]
|
(defn vec-to-comp [v]
|
||||||
|
|
Loading…
Reference in New Issue