Disable RTG enter and/or exit Transitions using the `enter`, and `exit` Props

Rory Smith
InstructorRory Smith
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 6 years ago

In React Transition Group, enter and exit transitions occur by default. However, sometimes that may not be the required behaviour. In this lesson, let’s take a look at how to change this behaviour, using the enter, and exit props.

Instructor: [00:00] Here, we have a button which toggles the appearance of a menu using CSS transition from React transition group. As well as the props that we're passing so far into our CSS transition, we can also make use of the enter and exit props. These are true by default.

[00:22] If we set enter to false, then these styles that we're using for our enter transition will not apply. The same can be said for when exit is false, these styles won't apply. Let's see that in action now. Let's pass enter equals false and refresh.

[00:47] Now, we get the exit transition, but not the enter transition. If we do exit equals false, we get no transition. This could be useful for when we want to keep hold of the CSS for our transitions, but we may want to dynamically disable the transitions, should our app require it.