I am trying to create a simple a TODO list app in ReactJS. My basics of React are not very clear so I am stuck here.
You need set this
for .map
(you can do that through second argument in .map)
return {this.props.items.map(createItem, this)}
;
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 -
{item.text}
;
};
return {this.props.items.map(createItem)}
;
Example