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

203
Views
Cómo pasar el icono MUI en una lista de mapas

Primero, importé el ícono AccountCircle de MUI:

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

Y usé estilo para darle estilo al ícono:

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

Y mi función de exportación se ve así:

 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> </> ); }

Esto es lo que parece cuando lo ejecuto: ingrese la descripción de la imagen aquí

He escrito dummyNotification como una lista de cadenas, y lo mapeo para que la notificación sea cada cadena en la lista. Quiero agregar un ícono de usuario (AcountCircle) en GreenBox antes de "Notificación __" para cada uno de los 3 cuadros. ¿Cómo haría eso aquí? Gracias de antemano.

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

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 Report

0

Si solo desea el ícono AccountCircle, puede codificar el ícono como <GreenBox><AcccountCircle /> {notification}</GreenBox> o si desea diferentes íconos para diferentes notificaciones, puede hacer algo como esto.

 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 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!