Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!