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!
Hi,
I'm looking at
Transitioninmasterand I'm trying to understand a design choice made in it because it affects the way my app works.Consider the following steps:
ENTEREDstatecomponentWillReceivePropsmethod takes the new state (EXITING) and stores it in an instance propcomponentWillUpdate, it sets its state with theEXITINGstateThe 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
EXITINGstate happens incomponentWillUpdateinstead ofcomponentWIllReceiveProps, 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!