The War Caster feat (PHB, p. 170) states that:
When a hostile creature's movement provokes an opportunity attack from you, you can use your reaction to cast a spell at the creature, instead of making an opportunity attack.
The rules on opportunity attacks state that:
The attack occurs right before the creature leaves your reach.
Xanathar's Guide to Everything states about reaction timing (p. 5) that:
If you’re unsure when a reaction occurs in relation to its trigger, here’s the rule: the reaction happens after its trigger completes, unless the description of the reaction explicitly says otherwise.
Should the first statement take into account the second? That is, does the ruling given as to order of resolution in the rules of opportunity attacks still hold even when the opportunity attack never actually takes place? Or does the ruling revert to the general case stated in the third statement?