Skip to content

Commit

Permalink
Update 14-communicate-between-components.md (facebook#7680)
Browse files Browse the repository at this point in the history
To demonstrate multiple arguments `bind(this, arg1, arg2, ...)`, also not to pass in for than what `handleClick` needed, namely props, or maybe even pass item itself, etc.
Going to change the kor file after review.
  • Loading branch information
exiadbq authored and acdlite committed Sep 9, 2016
1 parent aab4487 commit 6eaa6f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/tips/14-communicate-between-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ For child-parent communication:
Say your `GroceryList` component has a list of items generated through an array. When a list item is clicked, you want to display its name:

```js
var handleClick = function(i, props) {
console.log('You clicked: ' + props.items[i]);
var handleClick = function(i, items) {
console.log('You clicked: ' + items[i]);
}

function GroceryList(props) {
return (
<div>
{props.items.map(function(item, i) {
return (
<div onClick={handleClick.bind(this, i, props)} key={i}>{item}</div>
<div onClick={handleClick.bind(this, i, props.items)} key={i}>{item}</div>
);
})}
</div>
Expand Down

0 comments on commit 6eaa6f9

Please sign in to comment.