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

241
Vistas
MUI Slide Transition doesn't work with two Slide

I want the animation for each mui Slide to work when the button is clicked. But for some reason they don't want to work together. If you comment out one of the slides, the second one starts working, but together they don't.

Here's a link on codesandbox with my sample: https://codesandbox.io/s/happy-fire-csr2go?file=/src/demo.js

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

0

Because you use the isPink to control the rendering of the component, when the condition is not true, the component is unmounted when update, and no animation is performed.

// don't use this
{isPink ? (<div></div>) : (<div></div>)}

Code Fragment

        <Grid container item>
          <Slide
            in={isPink}
            direction="left"
            container={containerRef.current}
            mountOnEnter
            unmountOnExit
          >
            <Box
              sx={{
                position: "absolute",
                width: 150,
                height: 150,
                bgcolor: "pink"
              }}
            >
              <Button onClick={() => setIsPink(false)}>show aquamarine</Button>
            </Box>
          </Slide>
          <Slide
            in={!isPink}
            direction="right"
            container={containerRef.current}
            mountOnEnter
            unmountOnExit
          >
            <Box
              sx={{
                position: "absolute",
                width: 150,
                height: 150,
                bgcolor: "aquamarine"
              }}
            >
              <Button onClick={() => setIsPink(true)}>show pink</Button>
            </Box>
          </Slide>
        </Grid>

Full code demo

Edit TextField selectionStart

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