I am trying to animate a React component that contains data fetched from elsewhere. Placing it in a ReactCSSTransitionGroup
worked fine. That is, until I altered the component's render()
method to return false
until the data has been fetched (to prevent it from being rendered without data).
Now, I guess the component is mounted immediately, at which point the animation classes are added, but only rendered afterwards. Is this thinking correct? How can I get the component to be animated when render
returns the actual component?
ReactCSSTransitionGroup activates whenever components are added and deleted to its props.children
. Since your component is mounted before you fetch data, nothing will happen after data is fetched (I think this is true even if the component's render()
method returns false. Let me know in the comments if that is incorrect)
Just don't mount the component (in the solution, it's a <div key="1">
tag) until the react class receives the data. Use component states on the parent component to keep track of the state of your asynchronous request.