September 15, 2017 · clojurescript

Access this in clojurescript

To access this in a clojurescript function, use this-as macro

https://cljs.github.io/api/cljs.core/this-as

(def fadein-view
  (reagent/create-class
   {:get-initial-state
    (fn [this] {:hidden true
                :height 0})

    :component-will-appear
    (fn [cbk]
      (this-as this
        (reagent/set-state this {:hidden false})
        (cbk)))
...
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket