Fork me on GitHub
#reagent
<
2015-07-12
>
mikethompson00:07:33

@coyotespike: sounds like progress. But not sure why you have to de-refing the atom in each button component. Shouldn't be necessary.

Petrus Theron04:07:05

@coyotespike: that bit me too today. I wish reagent would warn me about it.

coyotespike16:07:57

Switching buttons with the if statement caused this warning:

coyotespike16:07:59

Warning: Returning "false" from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate.

coyotespike16:07:03

To prevent this, I added .-preventDefault to the button which triggered the switching.

coyotespike16:07:13

(defn blue-swap-button [showme label]
  (fn []
     [:input {:class "btn btn-info palette-turquoise"
              :type "button"
              :value label
              :on-click #(.-preventDefault (swap! showme not))}]))

(defn switch-buttons [atom default alternative]
  (fn []
    (if @atom
      default
      alternative)))
Where the button is default, and swaps out the atom, revealing the alternative.

coyotespike16:07:41

This fixed the warning. Anyone else run into this?

gadfly36116:07:30

That is the last discussion about it that I can remember, not sure if there is anything more current.

coyotespike16:07:24

Thank you! I found some IRC google archive, this is much more thorough.