cheapsteak / react-transition-group-plus

A more full-featured transition group for React
Other
268 stars 20 forks source link

Wrong hooks order #9

Open edoroshenko opened 8 years ago

edoroshenko commented 8 years ago

Let's say, we have two components (c1, c2) to replace with animation from c1 to c2. Let's say we replace them in out-in mode.

Then their hooks will be invoked in the following order: componentDidMount c2 componentWillLeave c1 componentDidLeave c1 componentWillEnter c2

I put here only hooks that I use in my app, but it's enough to get the idea.

It can be easily got round by hiding c2 element's node in componentDidMount hook and showing back in componentWillEnter, but it's desirable to be fixed to make the solution solid.

cheapsteak commented 8 years ago

Good point, although not sure what the ideal behaviour would be

I unfortunately don't think it'd be possible to actually delay the componentDidMount, since the mounting happens outside TransitionGroupPlus's control

Doing something like adding opacity: 0 to the component seems potentially heavy-handed? Input welcome