I drink lots of water, before, during and after. It often doesn't satisfy my thirst - maybe my body is telling me I need something else too.
I get no major adverse reactions from eating just before I exercise, except that I have a little less energy. One retired swim coach said food would make me heavier, and swim worse. But I'm not a great swimmer anyway.
I'd much rather consider my (relatively mild) type 2 diabetes, and make sure I have enough water and food in me to deal with any potential dangers. So I always eat, drink lots of water, and usually use a sports drink with calories (unfortunately sugars - not ideal for type 2 diabetes, but I figure I'm about to burn them away), sodium and potasium. It had not occurred to me to make sure I had enough magnesium, calcium, or vitamin C.
All I can do is read some more, experiment, and get more experience. Doubletoe's remarks give me some hope that it will go away with practice.
Oddly enough, some of the lifeguards, including guys who used to compete on swim teams, told me they sometimes cramp too. It's not just me.