The trick is don't overplay your hand.
Top pair is just that, 1 pair. Top pair is very vulnerable not to just an over pair, but 2 pair and sets, straights, flushes, ect... Going all in with top pair is a quick way to the rail.
I rarely go all in unless I have the nuts. I just don't see a need to risk all my chips until I make a hand.
Many players shove WAY too much and their stats show the results. If I had top pair I would want to GET VALUE for my hand. When you shove, you will get a fold or called by a better hand most of the time.
If you simply bet your hand and got a big re-raise, you could put the villain on possibly an over pair. If you slow down when faced with big bets and look at what
hands have you beat, your hand shrinks up fast, it may be a good fold.
Shove less, don't over play a pair, see more flops, and you will see positive results.