Will I still be able to breastfeed?

Hi ladies. I’m 30 weeks and 2 days, I just got discharged from the hospital and I found out I have gallbladder stones and when I have an attack it causes bad contractions. I got put on Nifedipine for contractions and Tylenol 3 for pain but they said if it gets too bad they will have to deliver my baby early and take out my gallbladder. Has anyone else went through this? Will I still be able to breast feed? I don’t like the thought of using formula but if i absolutely have to I will..