reagent

Drew Verlee 2025-11-05T22:25:48.474289Z

I have a reagent puzzle, feel free to see if you can figure it out before me. In a nut shell, this https://github.com/pyregence/pyregence/commit/b9c21052f4f3ba617f0615f79051cb8e6ed3f7da#r169744147 spells out my mystery. To rephrase, the fn i passed to the reagent classes :reagent-render wasn't being passed the same args the component was e.g (defn f [args] (r/clreate-class {:reagent-render (fn [args] ;; args were nil here but f was passed args . So i did some hacking and i discovered that down the call pipeline it looks like we did this (reagent.dom/render (cmpt instead of this [cmpt ... here where https://github.com/pyregence/pyregence/commit/cea4006be54ba7255848309bc4b2789f0efc7a66#r169744498, and where i change to to be a vector, and then it works. If anyone can bring come clarity to this, it would be appreciated.

Harold 2025-11-05T22:44:41.961239Z

Honestly, the AI kinda nailed it here...

👀 1
p-himik 2025-11-05T22:46:16.342479Z

Just never use (...) with Reagent components, ever. :) It's reasonably well documented. wrap-page is a form-2 component, but when you call it as a plain function it just returns another function. So you end up with (reagent.dom/render some-fn ...). When a function is passed to render, it gets called as a plain function as well, so it effectively turns into (render [:div ... from wrap-page ...] ...). That might not be a problem by itself though since wrap-page is not reactive. However, when you use #((uri->root-component-h uri) params), you end up with a function that immediately calls a view function on parameters. That view function is also a form-2 component. When you call it, it returns a closure with some parameters. But since you didn't use Hiccup, just closures, Reagent itself has never even seen those params - it cannot pass them again, they don't exist for Reagent.

👍 1
👀 1
p-himik 2025-11-05T22:47:03.404009Z

In other words, at some point you end up with (wrap-page (fn [params] ...)), but those params cannot come from anywhere.

p-himik 2025-11-05T22:48:49.520109Z

@hhausman I wouldn't say it nailed anything, to be honest... It just talked about efficiency and reactivity. The actual reason I outlined above isn't in the LLM-generated text at all.

Harold 2025-11-05T22:50:51.647099Z

> If you use (my-component props), the function my-component is called immediately, and its result (a data structure representing the UI) is placed directly into the parent's data structure. vs. > However, when you use #((uri->root-component-h uri) params), you end up with a function that immediately calls a view function on parameters. 🤷 simple_smile

Harold 2025-11-05T22:51:25.388039Z

@p-himik - you know I think you're one of the most helpful people around.

p-himik 2025-11-05T22:54:17.060259Z

> and its result (a data structure representing the UI) is placed directly into the parent's data structure Which is just false in the case of anything but form-1 components - there is no data structure, it's just a closure that expects arguments that never come. The context that the LLM has provided for that statement is just efficiency, not correctness. > you know I think you're one of the most helpful people around Appreciate it. :)