I use the following code to import React Material UI icons in my project;
import SupervisorAccountIcon from '@mui/icons-material/SupervisorAccount';
and I use them using;
<StyledTreeItem labelIcon={SupervisorAccountIcon} >
My data comes from the Laravel backend, and I would like to define which Icon will be used for each item in one of my database fields. So I can dynamically load or reference icons for each item when I build the display elements using React.
For that, I need to store an ID or name of the Icon in my database and retrieve the actual icon reference at the front end.
Is there any way to get an ID for MUI Icon, and how can I dynamically load Icon using its ID or name without hardcoding the Icon name? or even is this possible? Any help would be highly appreciated.