You need set this
for .map
(you can do that through second argument in .map
)
return <ul>{this.props.items.map(createItem, this)}</ul>;
Example
because now in createItem
this
refers to global (in browsers it will be window
) score (or if you use strict mode
this
will be undefined
)
as you use babel
you also can use arrow functions
var createItem = (item) => {
return <li key={item.id}>
{item.text}<input type="checkbox" onChange={this.Checked} />
</li>;
};
return <ul>{this.props.items.map(createItem)}</ul>;
Example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…