Fork me on GitHub
Elliot Stern12:03:25

I’m pretty new to clojure, and I’m trying to track down a bug in an existing re-frame application. Basically, if you navigate from the homepage to a subpage via a particular intermediate path (homepage > click on one link on the homepage > click on the subpage from the menu bar), one of the components on the subpage doesn’t update after a subscription updates. If you navigate to that subpage pretty much any other way, though, it works as expected and the component updates after the subscription updates. What are some things I should be looking for that might explain why this bug is happening?


If it's not, the second step would to be compare your app's state after navigating to the subpage via the "bad" way with the app's state after navigating via any "good" way.

Elliot Stern12:03:32

Looking at the state after navigating to the subpage both ways, the thing it’s subscribed to is there both times.

Elliot Stern13:03:46

The component looks like

(defn foo-select
  (let [filtered-foo-ids (rf/subscribe [::subs/foo-ids])
        foos (rf/subscribe [::subs/foos])]
    (fn []
      [:> Select
         {:disabled (empty? @foos)
          :mode :multiple
Looking at that link, you wouldn’t expect this to rerender just because the ::subs/foo subscription was updated, because it’s not a ratom?


Subscriptions return a Reagent reaction that behaves exactly like a ratom in terms of change propagation and view re-rendering. In this particular case, is it foos or filtered-foo-ids that causes the issue?

Elliot Stern14:03:11

foos . In particular, when the bug is triggered, the select is always disabled

Elliot Stern14:03:06

However, looking at the app-db in 10x, it looks like foos is a 2 element list


And what does util/data-test do?

Elliot Stern14:03:18

Looks like it assocs a :data-test item into the map when the environment isn’t prod


Just to be sure, add (js/console.log "FOOS" (empty? @foos)) right before [:> Select and see if it prints false when the corresponding input stays disabled. If that's the case, I would start digging into the implementation of Select.