React article Comment Model

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.