White vinegar will work to get rid of gnats by mixing some white vinegar in a bowl along with some dish soap.
The gnats will be attracted to the white vinegar and get into the bowl and be trapped in the bowl and eventually die from the soap and white vinegar.
But although white vinegar does work I find that apple cider vinegar tends to attract the gnats a lot better and does a better job at getting rid of gnats.
Pour some apple cider vinegar into a bowl and then add some dish soap to the apple cider vinegar like you would with the white vinegar.