when the iconId passed to Foo is invalid (for example, something like "foz" sent from the server), the entire application crashes
Since you have an components list with valid iconIds, you can simply check if the received iconId is valid or not as below:
// This will return undefined if no such iconId is present in the list
const iconData = components.find(c => c.iconId === iconId);
// If no such iconId found
if (!iconData) return null; // Or <DefaultComponent />
// Else render actual component
return <ComponentToRender />;