All perfect praise be to Allah The Lord of the Worlds and may His peace and blessings be upon our Prophet Mohammad and upon all his family and companions.
According to the reliable opinion of the Shafie legal school, if part of the Awrah (everything that is prohibited for a man or woman to uncover) was uncovered during prayer and the praying person didn`t cover it immediately, then their prayer is invalidated and should be re-performed. This is because a condition of the prayer wasn`t fulfilled, and that is covering the Awrah.
Imam An-Nawawi said: "Covering the Awrah is a condition for the prayer being valid. If part of the Awrah was uncovered during prayer, then the prayer is invalidated. This is whether that part was big or small, the person was man or woman, was praying in seclusion or before people, the prayer was voluntary or obligatory…" {Al-Majmou` Shareh Al-Mohathab, vol.3/pp.166}.
In conclusion, the woman who realized that part of her hair or Awrah was uncovered while praying should repeat the prayer. However, if she managed to cover that part immediately, then her prayer is valid and she doesn`t have to repeat it. And Allah Knows Best.