useMemo
useMemo caches a calculated value until dependencies change.
Example
const total = useMemo(() => items.reduce((s, i) => s + i.price, 0), [items]);Exercise
Cache a value.
(() => calc(), [a])Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.