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

156
Vistas
ternory operator giving error when used to show or hide a div react js

i am trying to hide a div when it is in mobile view i am using a ternory operator and i am getting error i cannot compltely hide the div becase it already has a ternory operator inside it how can i achive this

 {this.state.hidediv?
               (<div className="livechat">): (<div className="livechat2">)
                 } //error here 
                 {this.state.hidecaht ? (
                   <>
                     <a
                       href="#"
                       className="close"
                       onClick={() => this.hidechat(true)}
                     ></a>
                     <Livechat id={this.state.liveid} />
                   </>
                 ) : null}
               </div>

livechat2 has css display:none so it wont show up

imgenter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The issue is that you give an unclosed tag, try this:

<div className={this.state.hidediv ? "livechat" : "livechat2"}>
  {this.state.hidecaht &&
     <>
       <a
         href="#"
         className="close"
         onClick={() => this.hidechat(true)}
       ></a>
       <Livechat id={this.state.liveid} />
     </>
   }
</div>
about 4 years ago · Juan Pablo Isaza Denunciar
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