Current section: useEffect 16 exercises
Problem

Requirements for the Dependency Array

Transcript

00:00 Kelly the co-worker updated our use effect because now we only want the logs to happen when enabled changes and so we added this dependency array. The difference here is without the dependency array it'll happen every single time with the dependency array it should only get called when enabled

00:16 changes and right now that's not happening because we're using our own version of use effects and so every single time we render at all even if we're not changing enabled it is doing the console log we don't want to have that problem and so your job is to add support for the dependencies this is

00:35 going to be a little bit trickier than you might think because you have to not only store the dependencies along with the callback but also the previous dependencies so that you can compare the previous with the next ones and if there's no dependency array then you just need to make sure you call the effect callback if there is a dependency array then you need to compare it with

00:54 the previous one and each individual item in that array needs to be the same and if they are different then only then do you call it so I think you should be able to manage this one let's get into it