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

186
Vistas
Navigate back to previous page within a container/div

So I'm displaying page2 component after clicking the button as the setShowForm sets my state to true. So the problem I'm having now is how do I navigate back to my Page1 component as I have to display Page3 in Page1 so the ternary expression might seems a little bit complicated. I've tried using React-router-dom and useHistory, both of them doesnt work as I'm not switching between pages, just within a div.

<div className={styles.ticketBox}>
 { !showForm ? (
      //some UI code
      <div className={styles.whitelistBox}>
          <Button className={styles.whiteListToggleButton} shape="round" onClick={() => setShowForm(() => true)}>Whitelist</Button>
      </div>
</div>
) : (
    <Page2 />
)}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Pretty close, but to setShowForm you don't want to pass a function in, you just want to set it to true, ex:

// defining useState variables
const [showForm, setShowForm] = useState(false);

// setting to true
setShowForm(true)

// setting to true on click
onClick={() => setShowForm(true)}
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