"The way people treat you is a statement about who they are as a human being. It is not a statement about you."
One of the life lessons I've learned in interactions with people is that the way that others react towards us is a reflection of them and how they feel about themselves and less about us. This is whether they treat you negatively or positively. I have learned to not take other's attacks, criticism, or comments towards me personally. If you haven't done anything to hurt someone else, then the negative reaction is a reflection of who they are, and how they're treating you is a reflection of what or how they're feeling. So don't take it personally. When we feel good about ourselves, we usually treat people really well, we see the good in everyone. When we don't feel good about ourselves or our situation, we tend to look for the negative, complain and criticize and judge others.
So if a person lashes out at you for no reason, remember to not take it so personally. You don't know what they're dealing with or going through. Also, if you take some time to think about yourself and how you think or treat people and find that you don't see the good, take some time to find out what's bothering you. What do you need to help yourself feel better? There are a ton of tools and things to help you once you pin point the pain point.