shadow-cljs

defa 2025-03-10T09:02:45.552199Z

I just added a modal dialog to my reagent/re-frame project, code is in a new namespace. The namespace reloads (js/console.log debug output) but if I make changes to the component, they will not update (although the namespace did reload). Changes in other files are shown immediately. What do I miss? (It's been a while since I used shadow and reagent... maybe I just forgot something essential here?)

defa 2025-03-10T09:25:51.790589Z

Reloading the page in the browser will show the change but not hot-reloading for some reason?

defa 2025-03-10T10:34:38.340569Z

I found the problem... I "installed" the modal dialog in a conditional (case) part of my DOM tree and that might have prevented reagent to update.

thheller 2025-03-10T10:35:51.394679Z

see "Things to avoid"

thheller 2025-03-10T10:36:17.921849Z

could just be that reagent/react decide that the component doesn't need to re-render because something in the component tree wasn't actually updated

defa 2025-03-10T10:46:25.125279Z

Thanks for the hint @thheller. In my case I have some "tabbed" ui, where a case statement decides which tab content to render. I defined the model dialog (reagent component) within one of these tabs. Although this particular tab and the dialog were visible, the dialog did not update. Lifting the modal dialog in the DOM hierarchy outside the case statement did fix the problem. I'm not happy with this solution because the dialog is part of the tab and this kind of breaks the modularity of the code.

defa 2025-03-10T10:47:38.440149Z

(case (:inspector @state)
          :schematic [:div#inspector-column
                      [component-list]
                      [inspector]]
          :simulator [:div#inspector-column
                       [simulation-panel]])

defa 2025-03-10T10:48:25.402989Z

When setting up the modal dialog in the simulation-panel component hot realod did not work as expected...

defa 2025-03-10T10:50:29.397419Z

Defining the modal dialog right before or after the case statement fixes the update problem. It is not related to hot reload and has probably nothing to to with shadow-cljs.

defa 2025-03-10T10:51:01.279209Z

Or maybe it is some combination of hot-reaload and relagent.