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

160
Visualizações
React equivalent for ng-class

I have this component in angular. I am trying to make it work for react. I have changed most of the directives present in the original angular code but got stuck with ng-class. I know I can use the 'classnames' npm package to achieve the exact thing. But my project doesn't allow to install any third party package. I have done some research that I can also use classList from plain js to achieve it but, I am confused in how to implement it.

import React from 'react';

export default function commentNest(props) {
 return (
  <>
   <div className="su__row su__mx-sm-0 su__pt-sm-0  su__no-gutters">
    <div className="su__w-100 su__px-sm-0">
     <div className="su__tabing su__bg-white su__radius-1" ng-class="{su__loading: loadingResults}">
      <div className="NavBar">
       {props.clientFilters.sort((a, b) => {return a.index - b.index}).map(function (filter) {
        <div className="navbar-filter" style={{ display: clientFilters[0] && filter.values.length !== 0 ? 'block' : 'none' }}>
         <div style={{ display: filter.key == '_index' ? 'block' : 'none' }} className="su-tabsSection su__loading-view su__w-100 su__border-b su__text-nowrap" style={{overflowX: 'auto'}}>
          <div ng-class="{'active-type': activeType === 'all' && !users && !privateMessage }" className="inactive-type su__font-regular font-14 tabs su__cursor su__text-nowrap" onClick={() => callElasticFilterChange(true,'_index', 'all', 0, 0)}>
           {{languageDs['All Content']}}
          </div>
          {
           props.filter.values.map(function (filterType) {
            <div ng-class="{'active-type': activeType == filterType.Contentname && !users && !privateMessage}" className="inactive-type su__font-regular font-14 su__cursor su__text-nowrap tabs" onClick={() => callElasticFilterChange(filterType.selected,filter.key, filterType.Contentname, filter.order, $index)}>
             {{filterType.displayName === 'Sources' ? languageDs['Sources'] : filterType.displayName }}
            </div>
          })}       
          <div onClick={() => getUsers('Best Match','score')} ng-class="{'active-type': users}" className="inactive-type su__font-regular font-14 su__cursor su__text-nowrap tabs">
           {{languageDs['USERS']}}
          </div>
         </div>
        </div>
       })}
      </div>
     </div>
    </div>
   </div>
  </>
 );
};
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use

<div className={`someClass ${someVar ? 'active' : ''} ${anotherVar ? 'someClass' : 'otherClass'}`}>
....
</div>
about 4 years ago · Juan Pablo Isaza Relatório

0

You should check these NPM packages: clsx, classnames

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