Uncaught TypeError: inst.render error is not a function indicating a line number
function RenderComment(){
alert("Clicked");
ReactDOM.render(React.createElement("div", {}, React.createElement(Comment,{})),
document.getElementById('content')
);
}
I also get a warning
Warning: comment (...): a method was found on the returned instance of the component render: you may have forgotten to determine whether you renderreturned null / false from the stateless component or tried to display an element, type is a function that is not a React component.
All my Jact React code
<script type="text/babel">
var CommentBox = React.createClass({
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
var initializeScroll = 0;
loadCommentsFromServer: function() {
initializeScroll = initializeScroll + 5;
var data = {
"count": initializeScroll
};
$.ajax({
url: this.props.url,
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: JSON.stringify(data),
cache: false,
beforeSend: function(xhr) {
xhr.setRequestHeader(header, token);
},
success: function(result) {
this.setState({
data: this.state.data.concat(result)
});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
getInitialState: function() {
window.addEventListener("scroll", this.handleScroll);
return {
loadingFlag: false,
data: []
};
},
componentDidMount: function() {
this.loadCommentsFromServer();
},
handleScroll: function(e) {
var windowHeight = $(window).height();
var inHeight = window.innerHeight;
var scrollT = $(window).scrollTop();
var totalScrolled = scrollT + inHeight;
alert("Heeeeey");
if (totalScrolled + 100 > windowHeight) {
if (!this.state.loadingFlag) {
this.setState({
loadingFlag: true,
});
loading("on");
this.loadCommentsFromServer();
}
}
},
render: function() {
return ( < div className = "commentBox" >
< CommentList data = {
this.state.data
}
/> < /div>
);
}
});
var CommentList = React.createClass({
render: function() {
var commentNodes = this.props.data.map(function(comment) {
return ( < Comment > {
comment
} < /Comment>
);
});
return ( < div className = "commentList" > {
commentNodes
} < /div>);
}
});
var Comment = React.createClass({
rawMarkup: function() {
var rawMarkup = marked(this.props.children.toString(), {
sanitize: true
});
return {
__html: rawMarkup
};
},
render: function() {
return ( < div className = "comment" >
< span dangerouslySetInnerHTML = {
this.rawMarkup()
}
/> < /div>
)
}
});
ReactDOM.render( < CommentBox url = "/myUrl/abcd" / > ,
document.getElementById('content')
);
<script>
What I'm trying to do is scroll the web page (endless scroll) and download the content from the server - AJAX - a kind of thing + JQuery (for endless scroll_ + React JS. Please help me. I spent this whole weekend.