ckirkendall / kioo

Enlive/Enfocus style templating for Facebook's React and Om in ClojureScript.
Eclipse Public License 1.0
404 stars 39 forks source link

do-> with a lifecycle or a listen on react events seems to short circuit renders #58

Closed gigasquid closed 8 years ago

gigasquid commented 8 years ago

When we have some code like:

(do->
  (listen :onUpdate (fn [e] (.log js/console "not printing")))
  (content "Not rendered"))

The same thing happens with the lifecycle

(do->
  (lifecycle {:will-mount blah :will-update blah}))
  (content "Not rendered"))

Flipping the order of the expressions also short circuits.

Here is the funny bit: listening to the onRender gets the events, but the kioo content still doesn't happen

(do->
  (listen :onRender (fn [e] (.log js/console "does print!")))
  (content "Not rendered"))

onRender's behavior stays the same even if you swap expression order.

gigasquid commented 8 years ago

Found part of the problem. It seems to work if the lifecycle includes :should-update returning true

(do->
     (content (:copy-data app))
     (lifecycle  {:should-update (fn [this next-props next-state] true) ;; This needs to be here
                      :did-update (fn [this prev-props prev-state] do-all-the-things)))}))

Also true for listen :onUpdate to work. Need to have the lifecycle with should-update true

ckirkendall commented 8 years ago

Thank you for finding this. I have pushed a fix up and would love if you could test it out in your app.

gigasquid commented 8 years ago

Works great! Thanks :fish_cake: