Why isn't my re-frame component reloading on data change?

I have the following, which I want to see change whenever things cause :events in my DB to change. Why doesn’t it update in real-time?

(defn timeline
  "Timeline Component"
  []
  (let [timeline-id "timeline"
	events (rfc/subscribe [:events])
	invoke #(invoke-timeline! timeline-id @events)]
    (r/create-class
     {:component-did-mount invoke
      :component-did-update invoke
      :display-name "timeline-viz"
      :reagent-render (fn []
			[:div {:id timeline-id}
			 [:h1.title "Timeline"]])})))

You are not derefing the events inside your component. You can do sth like this to let Reagent know that you want to redraw the component when events change.

:reagent-render (fn []
                  @events
                  [:div {:id timeline-id}
                   [:h1.title "Timeline"]])
1 Like

You’ll need a two level arrangement.

This resource will get you going in the right direction

1 Like

Excellent resource. Thanks!

Ah! I always get confused whether it’s where I subscribe to the atom, or where I deref it. Thanks! Having done this, I found the deeper problem that the underlying library simply isn’t compatible with React updates (on data change, it appends multiple blank things into the place, rather than replacing anything, and they don’t seem to have compatible data-stores). Time to rewrite the library in happy cljs.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.