Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs tips fix small typo and code #775

Merged
merged 1 commit into from
Jan 1, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/tips/15-expose-component-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ var Todos = React.createClass({
return {items: ['Apple', 'Banana', 'Cranberry']};
},

handleClick: function(i) {
var items = this.state.items;
items.splice(i, 1);
handleClick: function(index) {
var items = this.state.items.filter(function(item, i) {
return index !== i;
});
this.setState({items: items}, function() {
if (items.length === 1) {
this.refs.item0.animate();
Expand All @@ -56,4 +57,4 @@ var Todos = React.createClass({
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.