From my experience, this is probably one of the most important factor. Anxiety and depression are highly associated with a positive family history. It is difficult to conclude with certainty whether this is truly genetic, or whether it is due to family conditioning, but I suspect that both factors are probably important.
The analogy I use for genetic factor is this. If life is 30 units of stress, then someone with a very strong family history of depression and anxiety might produce 60 units of stress. Everyone has a threshold at which they develop unhealthy stress and anxiety. However, someone who is producing more stress chemicals will obviously be more vulnerable to developing depression and anxiety.
The higher the genetic component is for one's depression and anxiety, the more likely one will need medications. My analogy here for medications is that it "recalibrates" the stress chemicals or. Unfortunately, we still don't have a clear idea of exactly how antidepressants work.