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

169
Views
How to use React-Transition-Group to show and hide modal/dialog with animation?

I've built a modal/dialog component using React and Tailwind. Here is a codesandbox with my problem.

Now I would like to show and hide the modal with a nice animation like this one here.

I've tried creating this using the react-transition-group package.

My problem

Currently I have only managed to get it to work on entering the dom BUT that is while wrapping the entire Confirm.jsx component. This is not ideal because that would mean that everytime I want to use the Confirm.jsx somewhere in my app, I also have to wrap it with the <CSSTransition> component.

So Ideally, I want to add the <CSSTransition> component either in Confirm.jsx or Dialog.jsx but whatever I try, I cannot get these to work.

What am I missing here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here is the little change I've made.

I moved CSSTransition to your Confirm component and removed the early returns in Confirm and Dialog when open state is false

You were returning nothing when open state is set to null. This was canceling your exit animation. CSSTransition needs to have someting to render so that it can add exit animation classes while exiting. After the animation is complete, CSSTransition removes the childtren from the DOM as you have already set the unmountOnExit property

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!