React Getting started--------top level API

Source: Internet
Author: User

React.createclass

Parameters: Config (object)

Create a Reactclass (component Class), the parameter is an object and must have a render property method, the method must return a closed container (within the container can be used by other open-ended containers) or null/false (which means nothing is rendered):

var Component = React.createclass ({        render:function () {            returnthis. props.a==1  ? <div>123null        }    });    Reactdom.render (        <component a="1" />, document.body    );

Note: In this method, all this will be automatically bound to the constructor of the current component at the end of the call.

React.createelement

Parameters: Type (string/reactclass), [Props (object)],[children (reactelement)]

Creates a react element of the specified type, noting that the third parameter children can be any of the react elements.

 varComponent =React.createclass ({render:function () {return  This. props.a==1? <p>123</p>:NULL        }    }); Reactdom.render (React.createelement ('Div',NULL, React.createelement ('P',NULL, React.createelement ('span',NULL,'Hello,'), React.createelement ('span',NULL,'World ,'), React.createelement (Component, {a:1})), document.body);

React.cloneelement

Parameters: Type (reactelement), [Props (object)],[children (reactelement)]

Clones and returns a new reactelement (the inner child element is also cloned), the newly returned element retains the props,ref,key of the old element, and the new props is integrated (as defined in the second argument)

React Getting started--------top level API

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.