0

I have this reagent component that uses setInterval to change its state:

(defn foo []
  (let [value (atom 1)]
    (js/setInterval (fn [] (reset! value (rand-int 100)) (println @value)) 1000)
    (fn []
      [:p @value])))

I can see the value being printed, a different one each time, but the html doesn't change. Why is that?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

1 Answers1

1

And the answer is that I should have been using a reagent.core/atom instead of an atom.

Dan Prince
  • 29,491
  • 13
  • 89
  • 120
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622