Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

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

    Rory SmithRory Smith
    reactReact
    ^16.0.0

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 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.

    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.

    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.