Wednesday, 15 September 2010

asp.net mvc - React.NET uncaught TypeError: undefined is not a function -



asp.net mvc - React.NET uncaught TypeError: undefined is not a function -

i trying larn reactjs , found react.net.

followed tutorial on author's website alter beingness mvc 5 app instead of mvc 4.

here jsx:

/** @jsx react.dom */ var commentbox = react.createclass({ render: function() { homecoming ( <div classname="commentbox"> <h1>comments</h1> <commentlist data={this.props.data} /> <commentform /> </div> ); } }); react.rendercomponent( <commentbox data={data} />, document.getelementbyid('content') ); var commentlist = react.createclass({ render: function() { var commentnodes = this.props.data.map(function (comment) { homecoming <comment author={comment.author}>{comment.text}</comment>; }); homecoming ( <div classname="commentlist"> {commentnodes} </div> ); } }); var commentform = react.createclass({ render: function() { homecoming ( <div classname="commentform"> hello, world! commentform. </div> ); } }); var info = [ { author: "daniel lo nigro", text: "hello reactjs.net world!" }, { author: "pete hunt", text: "this 1 comment" }, { author: "jordan walke", text: "this *another* comment" } ];

it gives error:

uncaught typeerror: undefined not function

any clues on one?

regards.

there 3 steps in snippet.

first, define commentbox:

var commentbox = react.createclass...

second, render commentbox , commentlist:

react.rendercomponent...

third, define commentlist:

var commentlist = react.createclass...

so, problem commentlist rendered before commentlist defined. if lastly 2 steps switched around work fine. commentlist class needs defined before can rendered.

asp.net-mvc reactjs

1 comment: