If you can predict it happening then try to catch her hand before she can dish out the slap and say something like Your not going to hit mummy are you in a gentle but firm voice, that way instead of telling her off for hitting you you can praise her for not hitting you.
Good idea to try catch her hands before the action, but avoid praise. Read Punished by Rewards, and the set of articles called The Price of Praise from Life Learning magazine.
Also, I wouldn't even use the word "hit" or "hitting."
I would hold the hands and just say loud and clear "Woops, here, you can bang the pillow."