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

123
Vistas
Why do I get these errors with my ternary operator?

This is what I get in the console: Unnecessary use of boolean literals in conditional expression no-unneeded-ternary.

I'm just trying to do a ternary operator that validates the state of a game and only if the game has started and the user.role is equal with player I disable the button. I am using reactjs and with the help of FormField hook I am making a form.

disabled ={(game.state === 'started' && user.role === PLAYER) ? true : false} 
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The ternary operator is unnecessary:

disabled ={(game.state === 'started' && user.role === PLAYER)} 
about 4 years ago · Juan Pablo Isaza Denunciar

0

No need to use statements in this case, ESlint is letting you know it's redundant since the value produced from this statement is already a boolean and you can create a simpler code.

Just write:

disabled = {(game.state === 'started' && user.role === PLAYER)}
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