reactjs - React Tutorial - Cannot read property 'toString' of undefined -
i need learn react in next day , started official tutorial. until state of code getting error , not sure how around it:
</head> <body> <div id="content"></div> <!-- script type="text/babel" src="scripts/example.js"></script --> <script type="text/babel"> var commentbox = react.createclass( { render: function() { return ( <div classname = "commentbox"> <h1>comments</h1> <commentlist /> <commentform /> <comment /> </div> ); } }); var commentlist = react.createclass({ render: function () { return ( <div classname = "commentlist"> <comment author = "michael johnson">this 1 comment</comment> <comment author = "daniel kammer">this 'second' comment</comment> </div> ); } }); var commentform = react.createclass({ render: function () { return ( <div classname = "commentform"> hello, world! commentform. </div> ); } }); var comment = react.createclass({ var md = new remarkable(); render: function () { return ( <div classname = "comment"> <h2 classname = "commentauthor"> {this.props.author} </h2> *** error generated below statement *** {md.render(this.props.children.tostring())} </div> ); } });
the rest of tutorial continues forward md.render statement - need understand how resolve error
it's caused <comment />
in comentbox
component, probably. children components required proper work of comment
component, closed tag has no childrens (this.prop.childrens
null or undefined => method tostring
not declared)
Comments
Post a Comment