Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda