News for hackers. Stuff that matters.
Re:How does one build large front end apps without using a f... by adithyassekhar on Friday October 17, 2025 @08:08AM (#45615807)
Could you please tell me how are you avoiding hooks? You're not using useState or useEffects?
Re:How does one build large front end apps without using a f... by Octoth0rpe on Friday October 17, 2025 @08:15AM (#45615859)
class components (which do not use hooks) are still supported by React with no scheduled deprecation AFAIK.
Re:How does one build large front end apps without using a f... by CaptainOfCoit on Friday October 17, 2025 @08:10AM (#45615819)
I mainly use React via Reagent in ClojureScript, and literally have no use cases where I need to use useState/useEffects for anything.

Turning it around, what aren't you able to do with useState/useEffects?

Re:How does one build large front end apps without using a f... by adithyassekhar on Friday October 17, 2025 @08:53AM (#45616178)
When I want to memoize something slightly complex, for simplicity's sake let's say sorting an array of objects based on one of it's keys. I can put that in a useMemo and it won't sort it again when the page eventually rerenders for some reason.

Usually that array is mapped elsewhere and those child components might also re render if the array is recalculated.

useEffects are when I need to call something outside of react, or when the page gets mounted or I need to call a function when something changes.

I'm still fairly new to this, the above examples may scream bad architecture to those more experienced, all criticisms welcome :)

Re:How does one build large front end apps without using a f... by Octoth0rpe on Friday October 17, 2025 @12:08PM (#45618345)
> all criticisms welcome :)

No criticism really. Your useMemo example is the right use. Your useEffect use is fine, but for things like api calls (which 'call something outside of react' may refer to), you're often better leaning on something like react-query, which is of course built on top of useEffect. So still the right tool, but let others handle many of the sharp edges around that problem.

Re:How does one build large front end apps without using a f... by adithyassekhar on Friday October 17, 2025 @06:06PM (#45622694)
Thanks. I've started with rtk and saga hence the useEffect. I've since moved to rtk query.
Re:How does one build large front end apps without using a f... by Our_Benefactors on Friday October 17, 2025 @09:39PM (#45624133)
> I can put that in a useMemo and it won't sort it again when the page eventually rerenders for some reason

useMemo dependency smell. This is almost always because your dependencies are wrong. This can often happen if you put a dependency as [object] instead of [object.field] due to how JavaScript maps objects to memory.

Re:How does one build large front end apps without using a f... by skydhash on Saturday October 18, 2025 @09:20PM (#45631486)
useMemo is quite nice when you're doing data transformation against some API call or other big data structure.
Re:How does one build large front end apps without using a f... by Our_Benefactors on Sunday October 19, 2025 @01:59AM (#45632292)
Yes, it is, but you still have to declare your dependencies correctly.
Re:How does one build large front end apps without using a f... by adithyassekhar on Monday October 20, 2025 @01:05AM (#45640301)
Never thought of it that way. What if it's an array though, how will I put it as a dependency?
Re:How does one build large front end apps without using a f... by homebrewer on Friday October 17, 2025 @01:03PM (#45619077)
One of the projects I sometimes work on uses class components + mobx; it runs circles around hooks in speed/debuggability/convenience IMHO.