Skip to content

Instantly share code, notes, and snippets.

@nrfm
Forked from dvingo/es6-class-react.cljs
Created October 20, 2017 13:07
Show Gist options
  • Save nrfm/2905ab942dd6642b885edd9206f53463 to your computer and use it in GitHub Desktop.
Save nrfm/2905ab942dd6642b885edd9206f53463 to your computer and use it in GitHub Desktop.
React component in pure cljs using ES6 class inheritance
;; 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