This is conditional or suspended talaq (talaq mu'allaq), and the scholars differ over it. The four madhhabs generally hold that once the condition occurs the talaq falls, because the man tied his divorce to it; but Shaykh al-Islam Ibn Taymiyyah and Ibn al-Qayyim distinguished the case where he did not intend divorce at all and used the words only as an oath to threaten, prevent or push himself or her into something, in which case no divorce falls and he pays the expiation of a broken oath — reasoning from Allah's words after the Prophet ﷺ made something lawful unlawful for himself: "Allah has already ordained for you the absolution of your oaths" (Quran 66:2), and from the principle that "actions are but by intentions" (Sahih al-Bukhari 1; Sahih Muslim 1907). Because divorce is a serious matter that Allah restricted and regulated (Quran 2:229), a man in this situation must not decide alone from a fatwa he read online: he should present the exact wording and his intention to a qualified scholar or Islamic court. And the wider lesson is that swearing by divorce is a blameworthy habit that ruins households and should be abandoned entirely.
Q&A · Marriage & Divorce
If a man says "if you do such-and-such, you are divorced," does the divorce actually take effect?
Evidence — the daleel
On deen2u
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.