Facebook's react.js — object is not a function-Collection of common programming errors

There are two main issues going on here.

First, when React.renderComponent is called, CommentList hasn’t been assigned, and is therefore still undefined. This is causing an error because CommentBox’s render function refers to


which jsx compiles to

CommentList(null)

When this exectutes and CommentList is undefined, we get an error because undefined is not a function. To fix this, all we need to do is move the CommentList declaration before the call to React.renderComponent.

Second, Comment and CommentForm are not defined anywhere. We need to either remove the references to them, or bring in their declarations from the tutorial.

For reference, here’s a jsfiddle of the original code: http://jsfiddle.net/jacktoole1/nHTr4/

And here’s what the fixed up code looks like if we include the declaration of Comment but simply remove the reference to CommentForm: http://jsfiddle.net/jacktoole1/VP5pa/