Weeeellllll, There could be both, mites and gnats. The yellowing sounds premature, so it could be mites causing that. Look on the bottom of the leaves.

How to prevent? You have to use a powerful insecticide at any opening to the grow area. Air intakes need to have a good dose sprayed in when the fans are off. All corners of the room after washing the entire room with a chlorine/water mix.

Then, during Veg, at a minimum of once a week spray with Neem oil, about an ounce per quart, shaken, water should have set and not have chlorine. Spray the leaves. Once you go into flower, you want to not give too much after the first 3 weeks. You can also put about a teaspoon to tablespoon in a watering and give one dose in late vegetation directly into the soil, the plant will uptake enough to keep the mites away. You may also read the link I have on mites.

Gnats, are a real PIA but not something that will damage the plant. I found outdoor soil brings them in. Regardless, I keep a sticky fly tape in the rooms to get the stuff that flys.