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

169
Visualizações
CSS class style not getting updated after binding it

I am working on a react project and came across this issue. i am passing my custom class name ${row.customClass} to the component and i am trying to style the same like shown in the below CSS section. when i checked in the developer tools, i can see that the class sample is been added to the along with other class like shown in HTML section. but the style is not getting applied for the custom class sample. all other styles are getting applied. can anyone tell me what’s wrong?

return (
            <tr key={index}>
                {
                rows.map((row, index) => {
                    return <td key={index} className={`${classes.row} ${!row.status ? classes.disableRow : ""
                    }${row.customClass}`}> <customComponent></customComponent></td>
                    })
                    }
             </tr>
        )

CSS

const useStyles = makeStyles(
    (theme) => ({

        row: {
            padding: "10px",
            "& span": {
               wordBreak:"break-all"
              }
        },

        disableRow: {
            color: "grey"
        },
        sample:{
            background:"red",
        }
    })
);

HTML

<td class="makeStyles-row-42 sample"> <span>Data123</span></td>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You are passing to classNames the the key 'sample' instead of passing it the key associated with the class you create with makeStyles.

For example look at the other classes you add, you do

${classes.row}

Not

${'row'}

If you want to get the class associated with "sample" in your makeStyles you need to do this:

rows.map((row, index) => {
                return <td key={index} className={`${classes.row} ${!row.status ? classes.disableRow : ""
                }${classes[row.customClass]}`}> <customComponent></customComponent></td>
                })
            }

Where row.customClass needs to be 'sample'

about 4 years ago · Juan Pablo Isaza Relatório

0

I think your issue is that you missed space. try adding space between ${!row.status ? classes.disableRow : ""} and ${classes[row.customClass]}

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