For me the key is having a small reset routine right after the hand. If I take a bad beat where I was clearly ahead, I remind myself that getting the money in good is the only thing I can control. The result is just variance doing its job.
Sometimes I’ll also take a short break, stand up, walk a little, or grab some water. Even a couple of minutes away from the table helps clear the emotional reaction so it doesn’t affect the next decisions.
In the long run, I try to view bad beats almost as confirmation that I played the hand correctly. If the chips went in with the best of it, that’s actually a good sign for future results, even if that particular pot didn’t go my way.