Exactly...
I learned from others' experience and I always carry a spare hanger. I remember the 1st time if happened to me out on the trails...
Was taking a turn on a mate's new bike so he was on mine. About 2 minutes later, I hear a snap, etc. from behind me and look around and my mate's standing looking at the rear mech of my bike. He starts apologising and I calmly say it ok, give me a minute..
Upturn the bike, produce a hanger from my pack, swap it over ..... and jobs a goodun'
Needless to say, the others in the group all ordered spare hangers for their bikes after that ride