I am using react and trying to import images and then dynamically display them.

import DE from 'assets/flags/flag_DE.png'; import US from 'assets/flags/flag_US.png'; import GB from 'assets/flags/flag_GB.png'; const countries = [ { code: DE }, { code: GB }, { code: US } ];

Then in my render method I loop over the countries and want to display the flag based on the country code.

<img src={country.code} />