DEV Community

loading...

Discussion on: The state you've never needed

Collapse
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.

Collapse
macsikora profile image
Maciej Sikora Author

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