React Study Notes 3

Source: Internet
Author: User

      <DivID= "Demo"></Div>        <Scripttype= "Text/babel">            varitemcomponent=React.createclass ({render:function (){                    return (                        <Li>{ This. Props.item}</li>                    )                    }            }); varlistcomponent=React.createclass ({render:function (){                    return (                        <ul>                            {                                 This. Props.listArr.map (function(item,index) {return <itemcomponent Key={Index} item={Item}/>                                })                            }                        </ul>                    )                    }            }); varfirstcomponent=React.createclass ({mixins:[react.addons.linkedstatemixin], getinitialstate:function (){                        return{mes: This. Props.value, Listarr: This. Props.listarr}}, Render:function (){                        return (                            <Div>                                <H1>{ This. Props.title}</h1>                                <input type="text"ref="Text_input"Valuelink={ This. Linkstate ("mes")} />/*introduction of React- with-Addons Library, and configure Mixins:[react.addons.linkedstatemixin], you can use Linkstate, similar to two-way data binding, in fact, the intrinsic implementation of the onchange event*/                                /*The ref attribute enables the current element to be found through This.refs.text_input*/                                <input type="Button"OnClick={ This. Additemhandle} value={ This. Props.sendname}/>                                /*This points to the problem, not understanding*/                                <P>{ This. State.mes}</p>                                <listcomponent Listarr= { This. State.listarr}/>

/* use THIS.STATE.LISTARR here instead of THIS.PROPS.LISTARR because the state is mutable, to pass the changed value to the subassembly */ </div>)}, Additemhandle:function (){ varvalue= This. Refs.text_input.value; varNEWARR= This. State.listArr.concat ([value]) This. SetState ({Listarr:newarr})}}); varobj={title:'react', Sendname:'Submit', Value:"Please enter a message", listarr:[1,2,3,4,5,6,7,8]} reactdom.render (<firstcomponent {... obj}/,document.getElementById ("Demo"), function() {Console.log ("Page Rendering Complete"); } );/*JSX do not write a semicolon, will error*//*class is a keyword and is written classname*//*when you set a style, write the form sytle={xx:xxx}*/ </Script>

React Study Notes 3

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.