Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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/ this props context updater)))
(js/goog.object.extend (.-prototype MyReact)
#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