DEV Community


Discussion on: The state you've never needed

meereenee profile image
Enes Kahrovic

Thank you for such an excellent series.
Just one small point. React can help us with delaying the evaluation:

const lionExists = useMemo(() =>
animals.some(animal => animal.type === 'lion'), [animals]);

So, it will be recalculated only when animals is changed.

macsikora profile image
Maciej Sikora Author

Yes, that is very good comment. Thank you Enes.