-
-
Save dvingo/c598fc6f90586e1d295e9a43c8ec7087 to your computer and use it in GitHub Desktop.
React component in pure cljs using ES6 class inheritance
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
;; implementing a React component in pure cljs, no reagent necessary | |
;; using goog.object.extend to create a ES6 class that inherits from | |
;; React.Component | |
;; credit to @thheller | |
(defn MyReact [props context updater] | |
(this-as this | |
(js/React.Component.call this props context updater))) | |
(js/goog.object.extend (.-prototype MyReact) | |
js/React.Component.prototype | |
#js {:render | |
(fn [] | |
(this-as this | |
(js/React.createElement "h1" nil "hello world")))}) | |
(js/ReactDOM.render (js/React.createElement MyReact) js/klipse-container) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment