Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Material Ui: Change mu icons props in array dinamically

I need change props (color, size) for many icons in array (and I use mu v4):

const ICONS_ARRAY: React.ReactNode[] = [
<AlertCircleCheckOutline />,
<AppleSafari />,
<MotionPlay />,
<AppleKeyboardCommand />,
<FileDocumentMultipleOutline />,
<ClipboardArrowLeftOutline />,
<ViewDashboardOutline />,
<CalendarClockOutline />,
<RobotHappyOutline />,
<AccountWrenchOutline />,
<AccountGroupOutline />,
<AccountCogOutline />,
<RunFast />,
<SpeedometerSlow />]

I try this (i - index icon in array):

           <MenuItem>
                <Box>
                    <SvgIcon fontSize={'small'}>ICONS_ARRAY[i]</SvgIcon>
                </Box>
            </MenuItem>,

But icon not render. If I change ICONS_ARRAY[i] on element - it works, like this:

           <MenuItem>
                <Box>
                    <SvgIcon fontSize={'small'}><RunFast /></SvgIcon>
                </Box>
            </MenuItem>

Also I try React.cloneElement, but it work same.

So you have any idea what the problem could be and what is the solution?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm going to say something small, but just to dismiss.
Have you tried adding brackets "{}"?
something like this...

        <MenuItem>
            <Box>
                <SvgIcon fontSize={'small'}>{ICONS_ARRAY[i]}</SvgIcon>
            </Box>
        </MenuItem>

Or try this

    {ICONS_ARRAY.map((icon) => (
      <MenuItem>
        <SvgIcon fontSize={"small"}>{icon}</SvgIcon>
      </MenuItem>
    ))}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!