Browse Source

docs tips fix small typo and code

main
Cheng Lou 11 years ago
parent
commit
2fd497d2c5
  1. 9
      tips/15-expose-component-functions.md

9
tips/15-expose-component-functions.md

@ -29,9 +29,10 @@ var Todos = React.createClass({
return {items: ['Apple', 'Banana', 'Cranberry']}; return {items: ['Apple', 'Banana', 'Cranberry']};
}, },
handleClick: function(i) { handleClick: function(index) {
var items = this.state.items; var items = this.state.items.filter(function(item, i) {
items.splice(i, 1); return index !== i;
});
this.setState({items: items}, function() { this.setState({items: items}, function() {
if (items.length === 1) { if (items.length === 1) {
this.refs.item0.animate(); this.refs.item0.animate();
@ -56,4 +57,4 @@ var Todos = React.createClass({
React.renderComponent(<Todos />, mountNode); React.renderComponent(<Todos />, mountNode);
``` ```
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. 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.

Loading…
Cancel
Save