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

246
Vistas
How to nest if-else inside an if in JSX syntax using ternary?

I'm trying to achieve the following in JSX:

if (declineButtonMessage) {
    if (buttonDirection === 'column') {
        render button 1
    } else {
        render button 2
    }
}

I have this so far:

{declineButtonMessage && (
    
)}

And I tried smuggling this inside:

buttonDirection === 'column' ? <StyledDeclineButton buttonDirection={buttonDirection} title={declineButtonMessage} wide onPress={onSecondaryAction} /> : <SecondaryButton buttonDirection={buttonDirection} title={declineButtonMessage} wide onPress={onSecondaryAction} />

But it wasn't working and my linter was going wild. I imagine I'm doing some sort of JSX syntax error

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

0

This should help you

{
  declineButtonMessage 
    ? (buttonDirection === 'column' ? <button1 /> : <button2 />)
    : null
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

{!!declineButtonMessage && (buttonDirection === 'column' ? <button1 /> : <button2 />)}

Try this pls

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