React hooks: How to conditionally trigger hook

In my React Native app, I have a variable var1 that gets updated 10 times, and on the 10th time another variable flag gets set to true. I want to trigger useEffect on var1 only when flag == true. Is there a way to do this?