I don't typically comment on aspects of people's appearances because I try to avoid finding myself in a situation such as you've found yourself in, but I have witnessed it on many occasions, and I have never seen someone react poorly to receiving a compliment.
There are lines that can be crossed though. One common one is asking to touch the hair (which you didn't do). Many blogs written by women of African heritage who live among largely white populations confirm that compliments are generally fine, but asking to touch is a bad idea.
This blog on HuffPost puts it quite well
Yes, the first part is a compliment. I do appreciate that you appreciate my hair. However, by asking to touch my hair you’re making me feel like an exhibit in a museum.
She does go on to mention that it often seems like the only thing people can seem to compliment her on is her hair, so it's not a bad idea to look for other things to compliment her on, such as a choice in jewelry. I've had many women tell me that they prefer compliments on their clothing or jewelry rather than on their physical features. The reason for this is that those things are conscious choices that they've made which you are affirming with your compliments.
This article from the root also cautions to be aware of the context in which you give these compliments
Keeping in mind a general sensitivity toward people who don’t like to be put on the spot—especially when that would mean having their racial differences highlighted—keep your compliments between you and the owner of the hair, and don’t make a scene with your praise. Keep this in mind especially in situations in which her race and gender make her a minority (think classroom or boardroom versus coffee shop).
Most likely, you ran into a person who is uncomfortable with receiving compliments, so I wouldn't worry too much, but it is good to keep in mind the fact that you are pointing out a cultural difference, and there is unfortunately going to be some degree of risk that you make the other person uncomfortable.