One
Second, the Code
1 <!DOCTYPE HTML>2 <HTMLLang= "ZH-CN">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Hello, World</title>6 </Head>7 <Body>8 <Scriptsrc= "./react-0.13.2/react-0.13.2/build/react.js"></Script>9 <Scriptsrc= "./react-0.13.2/react-0.13.2/build/jsxtransformer.js"></Script>Ten <Scripttype= "TEXT/JSX"> One varstyle= { A Color:"Red", - border:"1px #000 Solid", - }; the varHelloWorld=React.createclass ({ - Render:function () { - return <P>Hello, { This. Props.name}</p>; - }, + }); - varHellouniverse=React.createclass ({ + getinitialstate:function () { A return { at Name:'Tim', - }; - }, - HandleChange:function(event) { - This. SetState ({name:event.target.value}); - }, in Render:function () { - return <Div> to <HelloWorld name={ This. State.name}></helloworld> + <BR/> - <input type="text"OnChange={ This. HandleChange}/> the </div> * }, $ });Panax Notoginseng React.render (<div Style={style}><Hellouniverse></hellouniverse></Div>, document.body); - </Script> the </Body> + </HTML>
Meaning and usage of the react state