Fungus Gnats are usually a sign of overly wet soil and although I hear people recommending those mosquito bits all the time, in my opinion, allowing longer drying intervals will prevent the issue in the first place. The adult gnats only live a couple of weeks but they lay eggs in the uppermost layer of moist soil and the larvae feed on organic matter in the soil before emerging in the flying adult stage and if the soil doesn't have enough time to dry a few inches down, the cycle will continue.
Here are links to a couple of short articles in our Learning Library with information regarding Fungus Gnats:
https://garden.org/learn/artic...
https://garden.org/learn/artic...