Skip to content

Understanding Transition exiting #303

Description

@juandopazo

Hi,

I'm looking at Transition in master and I'm trying to understand a design choice made in it because it affects the way my app works.

Consider the following steps:

  • Render a TransitionGroup with one Transition item
  • The Transition item is in ENTERED state
  • After a user action, remove the Transition item
  • The Transition element is going to start exiting. Exiting happens in the following stages:
    • First the Transition element is re-rendered
    • It's componentWillReceiveProps method takes the new state (EXITING) and stores it in an instance prop
    • In componentWillUpdate, it sets its state with the EXITING state
    • This causes a second re-render

The first re-render has the same status, so nothing should happen. Then the second re-render happens and the animation starts. This looks good in isolation. However, in the context of an application with a store, that first render might be dangerous. I could go into details about why I think it's dangerous, but I don't want to write a gigantic wall of text.

What I'd like to understand is why the switch to the EXITING state happens in componentWillUpdate instead of componentWIllReceiveProps, causing just one re-render instead of two, so I can make a decision about how to address my problem (fork ReactTransitionGroup, contribute a change or something along those lines).

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions