Model prototypes
Comment Box
<div classname= "Commentbox" >
<commentlist/>
<CommentForm/>
</div>
React, you can define a similar model
Here we can see our familiar models, such as Div H1, but we can also see our custom commentlist commentform.
And for this commentlist, I need to redefine this one word model, of course, he finally presented an array, a number of records display, similar to the forum we see a record.
The complete commentlist definition.
Var commentlist=react.createclass ({
render:function () {
var Commentnodes=this.props.data.map (function (comment,index) {
return (
<comment Author={comment.author} key={index}>
{comment.text}
</comment>
);
});
return (
<div classname= "commentlist";
{commentnodes}
</div>
);
}
}), which also contains the comment definition
var Comment = React.createclass ({
Render:function () {
var rawmarkup=converter.makehtml (this.props.children.toString ());
Return (
<div classname= "comment" >
<H2 classname= "Commentauthor" >
{This.props.author}
<span dangerouslysetinnerhtml={{__html:rawmarkup}}/>
</div>
);
}
});
We can see that it's over here.
So here is the basic structure of react, you can customize some tags, and then build your own HTML structure for each new tag. So HTML is more free to build, and there are some object-oriented ideas in it.
React article Comment Model