I have an icon.js file as shown below to export the icons of your need:
import RotateLeftIcon from '@material-ui/icons/RotateLeft';
const iconTypes = {
LEFT_ROTATION: <RotateLeftIcon />,
};
export const iconNames = {
LEFT_ROTATION: 'LEFT_ROTATION',
};
export const getIcon = (iconName, props) => {
const Component = iconTypes[iconName];
return <Component style={{ ...props }} />;
};
and I call them like this:
import React from 'react'
export default function TestingIcons() {
return getIcon(iconNames.LEFT_ROTATION, {
color: '#fff',
fontSize: '1rem',
});
}
When I do the above, I get this error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
How to fix this?