Created
August 24, 2017 13:51
-
-
Save thheller/7f530b34de1c44589f4e0671e1ef7533 to your computer and use it in GitHub Desktop.
class extends React.Component in CLJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-component [props context updater] | |
(cljs.core/this-as this | |
(js/React.Component.call this props context updater) | |
;; anything else you want to set-up. use goog.object/set on this | |
this)) | |
(gobj/extend | |
(.. my-component -prototype) | |
js/React.Component.prototype) | |
;; cljs-specific properties on constructor | |
;; just so (prn my-component) works properly, not actually required | |
(set! (.-cljs$lang$type my-component) true) | |
(set! (.-cljs$lang$ctorStr my-component) "MyComponent") | |
(set! (.-cljs$lang$ctorPrWriter my-component) | |
(fn [this writer opt] | |
(cljs.core/-write writer "MyComponent"))) | |
(set! (.. component-fn -prototype -constructor) my-component) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment