There is a real but small risk called juice jacking, where a tampered port tries to pull data or push malware while you charge. Modern iPhones and Androids ask 'Trust this computer / Allow data?' and default to charge-only, so declining that keeps you safe. To be sure, use a plain wall socket, your own power bank, or a USB data-blocker adapter that passes power but not data. For most people the pop-up is enough protection.
The risk is small but real. A charge-only cable or a little USB data blocker passes power but no data, so a dodgy port cannot touch your files. Phones also ask Trust this device first, so just tap no. A power bank sidesteps it entirely.
Modern phones also prompt 'Trust this device?' before any data moves, so as long as you tap no, a public port just charges. A power bank in your bag sidesteps the whole question though.
The risk (juice jacking) is real but rare. The easy defense is a charge only cable or a little USB data blocker, which passes power but no data. Then a dodgy port physically cannot touch your files.