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?
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 :)