{"id":6473,"date":"2014-04-18T06:52:23","date_gmt":"2014-04-18T06:52:23","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/facebooks-react-js-object-is-not-a-function-collection-of-common-programming-errors-2\/"},"modified":"2014-04-18T06:52:23","modified_gmt":"2014-04-18T06:52:23","slug":"facebooks-react-js-object-is-not-a-function-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/18\/facebooks-react-js-object-is-not-a-function-collection-of-common-programming-errors-2\/","title":{"rendered":"Facebook&#39;s react.js &mdash; object is not a function-Collection of common programming errors"},"content":{"rendered":"<p>There are two main issues going on here.<\/p>\n<p>First, when React.renderComponent is called, CommentList hasn&#8217;t been assigned, and is therefore still undefined. This is causing an error because CommentBox&#8217;s render function refers to<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>which jsx compiles to<\/p>\n<pre><code>CommentList(null)\n<\/code><\/pre>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>For reference, here&#8217;s a jsfiddle of the original code: http:\/\/jsfiddle.net\/jacktoole1\/nHTr4\/<\/p>\n<p>And here&#8217;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\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two main issues going on here. First, when React.renderComponent is called, CommentList hasn&#8217;t been assigned, and is therefore still undefined. This is causing an error because CommentBox&#8217;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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6473","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6473"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6473\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}