useMemo
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
useMemo e mban mend rezultatin e një llogaritjeje të rëndë dhe e rillogarit vetëm kur ndryshojnë varësitë. Përdore vetëm kur llogaritja është vërtet e ngadaltë — React Compiler shpesh e bën vetë.
EnglishEN
useMemo remembers the result of a heavy calculation and recalculates only when its dependencies change. Use it only when the calculation is really slow — the React Compiler often does it for you.
Si ta mendosh
Si ta shkruash përgjigjen e një llogaritjeje të gjatë, që mos ta bësh sërish.
Lexoje në anglisht
Like writing down the answer to a long calculation so you don't redo it.
Shembull kodijavascript
const teRenditura = useMemo(
() => [...termat].sort((a, b) => a.emri.localeCompare(b.emri)),
[termat],
);