Whenever someone corrects you, immediately assume that you’re wrong. Don’t fight back. Let the nafs taste what it hates.
Carefully investigate the matter privately. Then decide if you actually were right or wrong. Admit if you’re wrong. If you think you were right, consult a trusted friend first to make sure.
If he agrees, then if the person will take it well consider a private discussion to come to the truth of the matter together.
Avoid public retorts at all costs, worst of all on social media. The sunnah of taking things privately is always best for your akhira–if that’s not important to you, then you’ve grabbed hold of the rope of Shaytan.