@samitouri / QOS-React-2 / commits / e244df510d

docs tips fix small typo and code

Cheng Lou committed Dec 31, 2013 at 21:23 UTC e244df510dc7b55c3bc7ac6bfe67a8f20cce2e41
1 file changed +5 -4
docs/tips/15-expose-component-functions.md
+5 -4
@@ -29,9 +29,10 @@ var Todos = React.createClass({
29 return {items: ['Apple', 'Banana', 'Cranberry']};
30 },
31
32 - handleClick: function(i) {
33 - var items = this.state.items;
34 - items.splice(i, 1);
32 + handleClick: function(index) {
33 + var items = this.state.items.filter(function(item, i) {
34 + return index !== i;
35 + });
36 this.setState({items: items}, function() {
37 if (items.length === 1) {
38 this.refs.item0.animate();
@@ -56,4 +57,4 @@ var Todos = React.createClass({
57 React.renderComponent(<Todos />, mountNode);
58 ```
59
59 -Alternatively, you could have achieve this by passing the `todo` an `isLastUnfinishedItem` prop, let it check this prop in `componentDidUpdate`, then animate itself; however, this quickly gets messy if you pass around different props to control animations.
60 +Alternatively, you could have achieved this by passing the `todo` an `isLastUnfinishedItem` prop, let it check this prop in `componentDidUpdate`, then animate itself; however, this quickly gets messy if you pass around different props to control animations.