Skip to content

Commit 25c9d6d

Browse files
committed
Merge pull request #2068 from ChrisSki/patch-1
Update 09.1-animation.md
2 parents 5b4e2be + 99ed643 commit 25c9d6d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/docs/09.1-animation.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ You'll notice that when you try to remove an item `ReactCSSTransitionGroup` keep
8383
}
8484
```
8585

86+
### Animation Group Must Be Mounted To Work
87+
88+
In order for it to apply transitions to its children, the `ReactCSSTransitionGroup` must already be mounted in the DOM. The example below would not work, because the `ReactCSSTransitionGroup` is being mounted along with the new item, instead of the new item being mounted within it. Compare this to the [Getting Started](/docs/docs/09.1-animation.md#getting-started) section above to see the difference.
89+
90+
```javascript{12-14}
91+
render: function() {
92+
var items = this.state.items.map(function(item, i) {
93+
return (
94+
<div key={item} onClick={this.handleRemove.bind(this, i)}>
95+
<ReactCSSTransitionGroup transitionName="example">
96+
{item}
97+
</ReactCSSTransitionGroup>
98+
</div>
99+
);
100+
}, this);
101+
return (
102+
<div>
103+
<button onClick={this.handleAdd}>Add Item</button>
104+
{items}
105+
</div>
106+
);
107+
}
108+
```
109+
86110
### Animating One or Zero Items
87111

88112
Although in the example above we rendered a list of items into `ReactCSSTransitionGroup`, the children of `ReactCSSTransitionGroup` can be one or zero items. This makes it possible to animate a single element entering or leaving. Similarly, you can animate a new element replacing the current element, with the new element animating in while the current animates out. For example, we can implement a simple image carousel like this:

0 commit comments

Comments
 (0)