DEV Community

Discussion on: 8 React Performance Tricks: Make your app blazing fast!

Collapse
 
johnnycus profile image
Albert Itayev

In an example from 2nd technique, wouldn't it make more sense to just use empty array as useEffect dependency?

Collapse
 
sanderdebr profile image
sanderdebr

This is possible, but the linter will tell you that there is a missing dependency, in this case getCocktails(). useEffect is depending on external values that may change, when you set the dependencies as an empty array the effect will run just once when the component mounts.