Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

367
Vistas
How to map over array of colors for a datatable in React?

I'm using material ui table to map over data from API but each table row has a progress bar. I want to be able to give the progress bar different colors. Here's the code below...

const BorderLinearProgress = withStyles((theme) => ({
 
  bar: {
    borderRadius: 5,
    backgroundColor: "red"
    
  },
}))(LinearProgress);




export default function FeatureTwo() {
  
  const [hmoName, setHmoName] = useState([]);
  const [hmoProgress, setHmoProgress] = useState([]);

  const getHmo = async () => {
    try {
      //API call
    } catch (err) {
      console.log(err);
    }
  };

  

  

  return (
    
     
        
        <Table aria-label="customized table">
          <TableHead>
            <TableRow>
              <StyledTableCell align="left">HMO</StyledTableCell>
              <StyledTableCell align="left">Enrollment Progress{''} (Percent %)</StyledTableCell>
            </TableRow>
          </TableHead>
          <TableBody>
            <TableRow>
              <TableCell align="left" >
                {hmoName.map((name, idx) => {
                  return (
                    <button key={idx}>
                      {name}
                    </button>
                  );
                })}
              </TableCell>

              <TableCell align="left" >
                <div>
                 
                    {hmoProgress.map((number, idx) => {
                      return (
                        <div>
                        <div>
                          <span key={idx}>
                            {parseInt(number).toFixed(0)}
                          </span>
                          <span >
                            Progress
                          </span>
                          </div>

                          <span>
                            <BorderLinearProgress
                              variant="determinate"
                              value={parseInt(number).toFixed(0)}
                            />
                          </span>
                        </div>
                        
                      );
                    })}
                  </div>
               
              </TableCell>
            </TableRow>
          </TableBody>
        </Table>
     
  );
}


BordeLineProgress has a background color set to red, all the progress bar in each row has the BC red. I want to set different colors for each progress bar for each row.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda