Skip to content

Instantly share code, notes, and snippets.

@dvingo
Forked from pesterhazy/es6-class-react.cljs
Created February 11, 2017 13:22
Show Gist options
  • Save dvingo/c598fc6f90586e1d295e9a43c8ec7087 to your computer and use it in GitHub Desktop.
Save dvingo/c598fc6f90586e1d295e9a43c8ec7087 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