Skip to content
Snippets Groups Projects
Unverified Commit ee72f23f authored by Tim Mickel's avatar Tim Mickel
Browse files

Idiomatic "map"

parent 93645ea7
No related branches found
No related tags found
No related merge requests found
......@@ -17,22 +17,20 @@ class LibraryComponent extends React.Component {
this.setState({selectedItem: id});
}
render () {
let gridItems = [];
let itemId = 0;
for (let dataItem of this.props.data) {
let gridItems = this.props.data.map(function (dataItem) {
let id = itemId;
itemId++;
const scratchURL = (dataItem.md5) ? 'https://cdn.assets.scratch.mit.edu/internalapi/asset/' +
dataItem.md5 + '/get/' : dataItem.rawURL;
gridItems.push(
<LibraryItem
name={dataItem.name}
iconURL={scratchURL}
key={'item_' + itemId}
selected={this.state.selectedItem == itemId}
onSelect={this.onSelect.bind(this)}
id={itemId} />
);
itemId++;
}
return <LibraryItem
name={dataItem.name}
iconURL={scratchURL}
key={'item_' + itemId}
selected={this.state.selectedItem == itemId}
onSelect={this.onSelect.bind(this)}
id={id} />;
});
const scrollGridStyle = {
overflow: 'scroll',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment