I think Annie is right and I also think this is pretty normal stuff. My son is the same age and loves loves his gymnastics class. However, their attention spans are still pretty short, they are fairly easily distracted, and of course sometimes just don't feel like doing it. I wouldn't push. The idea is for them to be active and have fun, and in my experience with my child, pushing can turn them off the whole activity.
3 1/2 is pretty young to be expecting perfection from, especially in 'performance' versus at home. In other words, she might be suddenly conscious she is dancing while people are watching, and might be getting an attack of the shys. How long is the dance, and how complex? Is her class all 3-year-olds and they are doing it perfectly and she is stopping? She also might be feeling pushed or pressured, either by the teacher's insistence on her doing it right, or by yours. I'd take it as a signal that something about the situation is bothering her, no matter how much she likes to dance at home, and would take it seriously. I don't assume you are trying to train her up to be Britney Spears, it might be OK to ask her if she wants to stop dance class for a while, and see how she responds.