-
Notifications
You must be signed in to change notification settings - Fork 649
Description
Do you want to request a feature or report a bug?
Bug (or there's sth wrong with my code)
What is the current behavior?
During entering, the exited
state lasts for minimal amount of time, but sometimes it appears to be too little, such that the browser doesn't render the style associated to that state and the enter transition doesn't work.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/m4mb9Lg3/4/).
https://jsfiddle.net/m4mb9Lg3/25/
Note, that exit transition works properly, whilst entering is not transitioned. In console you can see however, that the state
prop is passed correctly and goes through it's whole cycle.
The other day, doing enter animations in pure React stateful component (no react-transition-group
), something similar occurred:
I would have an enteredActive
state, initially set to false
. In componentDidMount
, inside requestAniationFrame
callback I would set it to true
. This would trigger rendered styles change and thus animation. That's fine except it's not, because oftentimes (not always) this wouldn't work. What fixed it permanently, was to put the rAF
inside another rAF
, like this:
componentDidMount() {
requestAnimationFrame(() =>
requestAnimationFrame(
() => this.setState({ enteredActive: true })
)
)
}
My suspicion is that it has something to do with React internals.
So to the point: maybe the double-raf-technique inside Transition
component would help? Or yet, there's sth wrong with my codepen?
Which versions, and which browser / OS are affected by this issue? Did this work in previous versions?
All of them.