News for hackers. Stuff that matters.
Re:React I love you, but you're bringing me down by divs1210 on Tuesday September 20, 2022 @02:01PM (#32915484)
That is bonkers, to be honest.

I've used React a lot, but only via Reagent in ClojureScript.

I think the JS people are being scammed.

Re:React I love you, but you're bringing me down by UlisesAC4 on Tuesday September 20, 2022 @06:35PM (#32918685)
It is bonkers. My number of "accidental" re renders on react are greater than before hooks.

Before at least I knew what was called on boostrap moments. Now everything is run as a side effect when any dependency change. My needs on checking if a prop or a dependency has changed hasn't evolved at all. I just have the core of my side effects on useEffect.

Re:React I love you, but you're bringing me down by filoeleven on Wednesday September 21, 2022 @11:54AM (#32926981)
It sounds bonkers, but one of the reasons I pushed for moving my company’s app to React was because the useState hook reminded me of Reagent’s ratoms. I believe that was at least part of their intent. The catch is that you can’t really enforce immutability or atomic updates in plain JS, so they built hooks into the library as a workaround.

There’s not much of a cognitive difference between “defining a reagent component which uses ratoms and calls a pure function that derefs, updates or swaps them”, and “defining a react functional component that uses hooks”. It looks weird to have the “atoms” inside the render function instead of outside, and there are the aforementioned limitations (“the rules of hooks”), but it’s a compromise to get the feature into JS React in a consistent, performant manner.

I’d love to use CLJS/Reagent or even go full re-frame on our front-end codebase, but that’s a hard sell at my company since I’m the only dev who’s ever played with Clojure.

Re:React I love you, but you're bringing me down by origin_path on Wednesday September 21, 2022 @05:03AM (#32922433)
It's sort of what happens when OOP is demonized for years and FP is lionized. They've created what are effectively classes but with implicitly auto-generated private property names and a lot of weird edge cases where things can go pear shaped. But hey, it's functional and 'new' so it's good, right?

In fairness, the JS world has never had well engineered OOP GUI toolkits like you find in the desktop space. If you've never used JavaFX then ReactJS probably seems pretty magical. If you have, then, well ...

Re:React I love you, but you're bringing me down by divs1210 on Wednesday September 21, 2022 @07:00AM (#32923292)
You might need to re-read my comment.

ClojureScript is a functional language.

Reagent is a ClojureScript wrapper over React.

Cljs + Reagent is AWESOME.

There is a JavaFX wrapper too, with a similar API.

Re:React I love you, but you're bringing me down by origin_path on Wednesday September 21, 2022 @07:37AM (#32923605)
I know, but you didn't actually say you think React is awesome when not using JS. Given how JS specific React is, that's not a very intuitive outcome.

The comment was in response to "that's bonkers". And that has been my reaction on learning stuff like React and derived frameworks. A lot of it looks like functions for the sake of it, when objects already solve those problems but became unfashionable.

Re:React I love you, but you're bringing me down by cutler on Tuesday September 20, 2022 @08:57PM (#32919757)
I don't know why Clojurescript's Reagent/re-frame aren't more popular given that they completely obviate the need for hooks or classes.
Re:React I love you, but you're bringing me down by divs1210 on Wednesday September 21, 2022 @07:01AM (#32923298)
I think someone should make a Reagent for JS.
Re:React I love you, but you're bringing me down by cutler on Wednesday September 21, 2022 @06:27PM (#32932405)
But Reagent is built on top of React.