Skip to content

Instantly share code, notes, and snippets.

@niwinz
Forked from dvingo/es6-class-react.cljs
Created April 8, 2017 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niwinz/e8234fd94d5fe99a2ca9885fc4178f1a to your computer and use it in GitHub Desktop.
Save niwinz/e8234fd94d5fe99a2ca9885fc4178f1a 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