How do I handle it? Poorly.
How should I handle it? Well, a few things:
If I haven't engaged yet, I should try to keep in mind whether it's worth my time to engage, whether I'm really qualified to represent the opposing viewpoint, etc. Often, I'm just not the right person or it's not the right time.
If I feel like I need to change this person's opinion in order to be okay, it's less about them and more about me. I probably feel like there's some part of my humanity that isn't being recognized here. The thing is: Responding to them by being hostile to their perspective is gonna make them feel exactly the same way, and neither of us are gonna get what we want.
It's much better to ask: "I'm curious why you see it that way. I see it differently, and here's why" focusing way more on what I'm subjectively bringing to table rather than what makes it an objectively better argument. Curiosity also invites them into a collaborative exercise instead of a zero-sum duel. It's crazy that we view online debates as like... if I learned something in the process, I'm the loser! What a weird way to look at it! If I phrase it in a way where we can both feel good about changing our minds just a little bit, we'll both feel way better.
It's also helpful to recognize the difference between positions and interests/motivations. Two people might both want an orange, but there's only one orange. Alice's position is "I want that orange". But their interest might be that they want to make orange juice with it. And Bob's interest might be that he wants to zest the peel to make an orange cake. They could easily both be happy here, but not realize it because they're stuck fighting on what to do instead of why they want to do that. Even if I don't get the discussion to that point, it can be helpful to assume that the other party has reasons for their position that are different from the reasons for mine, and they might both be valid.
And along those lines... just because I'm right doesn't mean the other person is wrong. Sometimes more than one thing can be true. The world is messy, the truth resists simplicity, and plenty of things -- and people -- are contradictory while still being valuable.
Finally: I should try to recognize when someone is simply acting in bad faith and cut my losses way before getting emotionally invested. Sometimes online content is literally a trap, and I don't have to keep walking towards it after already realizing it's a trap just because I'm curious what kind of trap it is. Innuendo Studios' series on "The Alt-Right Playbook" is a great guide to recognizing this behavior: https://www.youtube.com/playlist?list=PLJA_jUddXvY7v0VkYRbANnTnzkA_HMFtQ