Having some weird situation at least weird for me. I'm building timeline component so far so good. In case user timeline is empty i want to render different react class Here a portion of the code i did
var Timeline = React.createClass({
getInitialState: function() {
return {
data: [],
page: 0,
loadingFlag: false
}
},
loadTimelineFromServer: function() {
var nextPage = this.state.page + 1;
var url = this.props.url + '?page=' + nextPage;
$.ajax({
url: url,
dataType: 'json',
cache: true,
success: function(response) {
if (this.isMounted()) {
this.setState({
data: this.state.data.concat(response.data),
loadingFlag: false,
page: nextPage
});
}
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
componentDidMount: function() {
this.loadTimelineFromServer();
},
render: function() {
var items = this.state.data;
var renderer;
if (items.length) {
renderer = <TimelineList data=items />
} else {
renderer = <EmptyTimeline />
}
return (
<div>
{renderer}
</div>
);
}
});
EDIT : the error fired from firebug
Error: Parse Error: Line 71: JSX value should be either an expression or a quoted JSX text
at http://qfriends.dev/js/components/socialnetwork/user_timeline.js:71:20 ...pointing to this <TimelineList data=items />