Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
How to pass in MUI icon in a map list

First, I imported the AccountCircle Icon from MUI:

import { AccountCircle } from '@mui/icons-material';

And used styled to style the icon:

const UserIcon = styled(AccountCircle)({
margin: '0px 0px 0px 0px',
});

And my export function looks like this:

export default function Notifications() {
  const dummyNotification = [
    'Notification #1',
    'Notification #2',
    'Notification #3',
  ];

  const cardComponents =
    dummyNotification !== undefined
      ? dummyNotification.map((notification) => (
          <div key={notification}>
            <div>
              <GreenBox>{notification}</GreenBox>
            </div>
          </div>
        ))
      : 'Loading...';
  return (
    <>
      <NavBar />
      <Row>
        <RightCol>
          <div>{cardComponents}</div>
        </RightCol>
      </Row>
    </>
  );
}

Here is what it looks like when I run it: enter image description here

I have written dummyNotification as a list of strings, and I map it so that notification is each string in the list. I want to add a user icon (the AcountCircle) in the GreenBox before "Notification __" for each of the 3 boxes. How would I do that here? Thank you in advance.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0


function Notifications() {
  const dummyNotification = [
    {notif: 'Notification #1', icon: UserIcon },
    {notif: 'Notification #2', icon: UserIcon },
    {notif: 'Notification #3', icon: UserIcon },
  ];
    
  const cardComponents =
    dummyNotification !== undefined
      ? dummyNotification.map((notification) => (
          <div key={notification.notif}>
            <div>
              <GreenBox>
                <notification.UserIcon/ >
                {notification.notif}
              </GreenBox>
            </div>
          </div>
        ))
      : 'Loading...';
  return (
    <>
      <NavBar />
      <Row>
        <RightCol>
          <div>{cardComponents}</div>
        </RightCol>
      </Row>
    </>
  );
}

about 4 years ago · Juan Pablo Isaza Relatório

0

If you only want AccountCircle icon then you can hardcode the icon like <GreenBox><AcccountCircle /> {notification}</GreenBox> or if you want different icons for different notifications then you can do something like this.

export default function ControlledSwitches() {
  const UserIcon = styled(AccountCircle)({
    margin: "0px 0px 0px 0px"
  });
  const dummyNotification = [
    { text: "Notification #1", icon: <UserIcon /> },
    { text: "Notification #2", icon: <UserIcon /> },
    { text: "Notification #3", icon: <UserIcon /> }
  ];

  const cardComponents =
    dummyNotification !== undefined
      ? dummyNotification.map((notification) => (
          <div key={notification}>
            <div>
              <GreenBox>
                {notification.icon} {notification.text}
              </GreenBox>
            </div>
          </div>
        ))
      : "Loading...";
  return (
    <>
      <NavBar />
      <Row>
        <RightCol>
          <div>{cardComponents}</div>
        </RightCol>
      </Row>
    </>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda