I'm having some issues with React not displaying data relating to a component's props:
import React from 'react';
import {ItemListing} from './ItemListing.js';
export var SearchResults = React.createClass({
render: function() {
console.log('Render called! SearchResults props', this.props); // Fires and displays data as expected
return (
<div>
{this.props.items.forEach(function(item) {
console.log(item); // Fires correctly
<ItemListing item={item} /> // Does not run - a console.log() inside the render method of this component does not fire
})}
</div>
)
}
});
This component is loaded inside its parent as <SearchResults items={this.state.items} />, and the console.log() inside the render function above does show the props being loaded as expected (after initially loading as empty, as the data comes from an Ajax call further upstream).
However, the component inside the forEach loop doesn't appear to load, there's no display and a console.log() at the top of its render method doesn't seem to fire.
I'm very new to react so may be missing something obvious, but can anyone tell me what I'm doing wrong?