reagent

thheller 2025-06-27T11:31:37.686309Z

Heya, wrote a https://code.thheller.com/blog/shadow-cljs/2025/06/27/case-study-reagent-with-macro-help.html and kinda blindly used reagent. It has been a while, so I'm kinda unsure what an idiomatic solution would look like. Anyone interested to rewrite https://github.com/thheller/wthjh-evolution/blob/main/src/main/wthjh/reagent.cljs into an idiomatic variant so I can test against that and not my weird goals?

schadocalex 2025-06-30T11:59:47.891709Z

Hey, you should try with React 18 instead. Even your initial code will run smoothly. I wouldn't recommend to use reagent with React 19 (yet).

juhoteperi 2025-06-27T13:05:02.443969Z

Calling render multiple times is "incorrect", it will likely be quite slow.

juhoteperi 2025-06-27T13:06:34.886189Z

When using ratom for the state, the state updates will trigger correct components to update automatically. Reaction could be further used to optimise, so that when only one item is updated in the collection, just the component for that item is rendered, vs. all the components for all items (though if the item value doesn't change it likely won't render again as the value is the same, but it will check if the value changed.)

juhoteperi 2025-06-27T13:12:29.528399Z

I can create a updated version of the file later today

thheller 2025-06-27T13:53:13.512299Z

well the intent was to have all state and the root and render "down". the update happens from "outside", so can't have a ratom per "row"

juhoteperi 2025-06-27T15:11:51.811379Z

I guess one ratom and deref at the top level then?

juhoteperi 2025-06-27T15:16:15.753269Z

Depending on what do you want to test and show. But I don't think calling React render after every change is a real use case, or how it is supposed to be used. Not sure how it will work, maybe it works fine and if the component fns are the same as previously, it doesn't reinitialize the components and instead just updates the parameters. But ratom update triggers a re-render in a different way.

thheller 2025-06-27T18:47:53.954229Z

https://github.com/mohiji/wthjh-reagent/blob/main/src/cljs/wthjh/app.cljs this did the trick

thheller 2025-06-27T18:48:15.959699Z

just wanted a reference to show that the proper thing is actually fast