mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Christopher Chedeau vjeux Document isMounted … 30e16e4
Nick Thompson nick-thompson Clarify componentWillMount behavior542f20bCheng Lou chenglou docs fix back link in Examples6b15ad5Cheng Lou chenglou docs add jsx->js tab to live editors7ac5f3cPaul O’Shannessy zpao Normalize line endings6b1c6beBen Alpert spicyj Update homepage for new JSX/JS editor761e1c8Ben Alpert spicyj Properly clear live editor on JSX compile failured3fc5adBen Alpert spicyj Simplify live editor execution logicc7f0663Cheng Lou chenglou [docs] Tweak frontpage first example and jsx-compiler example8c8841cChristoph Pojer cpojer Update propTypes documentation.b66fbdeJean Lauliac jeanlauliac Update broken link in 'why react' article341d292Jean Lauliac jeanlauliac Normalize internal links in 'why react' article0681d13aymanosman aymanosman Fix typo09650e1Bob Eagan bobeagan fix incorrect link2edb76fBob Eagan bobeagan add hash link for lifecycle section of working with the browser page3db3460Pete Hunt petehunt remove references to react-page3120192Ben Alpert spicyj Fix docs typo6e4ddfdPaul O’Shannessy zpao Fix animation example code …dd66223Eric Schoffstall Contra fix grammar mistake64ac427Kunal Mehta kmeht Add documentation about React.renderComponent …f970453Christopher Chedeau vjeux s/Mock DOM/Virtual DOM/ …22772c9Ben Alpert spicyj Disable CodeMirror smart indentation …571d173Ben Alpert spicyj [docs] Fix comma splice3810c83
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -120,8 +120,8 @@ make views <strong>easier to extend and maintain</strong>.</li>
|
||||
vulnerabilities.</li>
|
||||
</ul>
|
||||
|
||||
<p>We've also created <a href="http://facebook.github.io/react/docs/syntax.html">JSX</a>, an optional
|
||||
syntax extension, in case you prefer the readability of HTML to raw JavaScript.</p>
|
||||
<p>We've also created <a href="/react/docs/jsx-in-depth.html">JSX</a>, an optional syntax
|
||||
extension, in case you prefer the readability of HTML to raw JavaScript.</p>
|
||||
<h2><a class="anchor" name="reactive-updates-are-dead-simple."></a>Reactive updates are dead simple. <a class="hash-link" href="#reactive-updates-are-dead-simple.">#</a></h2>
|
||||
<p>React really shines when your data changes over time.</p>
|
||||
|
||||
@@ -170,12 +170,10 @@ for SEO, performance, code sharing and overall flexibility.</li>
|
||||
<a href="http://davidwalsh.name/event-delegate">event delegation</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Head on over to
|
||||
<a href="http://facebook.github.io/react">facebook.github.io/react</a> to check
|
||||
out what we have built. Our documentation is geared towards building
|
||||
apps with the framework, but if you are interested in the
|
||||
nuts and bolts
|
||||
<a href="http://facebook.github.io/react/support.html">get in touch</a> with us!</p>
|
||||
<p>Head on over to <a href="/react">facebook.github.io/react</a> to check out what we have
|
||||
built. Our documentation is geared towards building apps with the framework,
|
||||
but if you are interested in the nuts and bolts
|
||||
<a href="/react/support.html">get in touch</a> with us!</p>
|
||||
|
||||
<p>Thanks for reading!</p>
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -245,8 +245,8 @@ make views <strong>easier to extend and maintain</strong>.</li>
|
||||
vulnerabilities.</li>
|
||||
</ul>
|
||||
|
||||
<p>We've also created <a href="http://facebook.github.io/react/docs/syntax.html">JSX</a>, an optional
|
||||
syntax extension, in case you prefer the readability of HTML to raw JavaScript.</p>
|
||||
<p>We've also created <a href="/react/docs/jsx-in-depth.html">JSX</a>, an optional syntax
|
||||
extension, in case you prefer the readability of HTML to raw JavaScript.</p>
|
||||
<h2><a class="anchor" name="reactive-updates-are-dead-simple."></a>Reactive updates are dead simple. <a class="hash-link" href="#reactive-updates-are-dead-simple.">#</a></h2>
|
||||
<p>React really shines when your data changes over time.</p>
|
||||
|
||||
@@ -295,12 +295,10 @@ for SEO, performance, code sharing and overall flexibility.</li>
|
||||
<a href="http://davidwalsh.name/event-delegate">event delegation</a>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Head on over to
|
||||
<a href="http://facebook.github.io/react">facebook.github.io/react</a> to check
|
||||
out what we have built. Our documentation is geared towards building
|
||||
apps with the framework, but if you are interested in the
|
||||
nuts and bolts
|
||||
<a href="http://facebook.github.io/react/support.html">get in touch</a> with us!</p>
|
||||
<p>Head on over to <a href="/react">facebook.github.io/react</a> to check out what we have
|
||||
built. Our documentation is geared towards building apps with the framework,
|
||||
but if you are interested in the nuts and bolts
|
||||
<a href="/react/support.html">get in touch</a> with us!</p>
|
||||
|
||||
<p>Thanks for reading!</p>
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -377,7 +377,7 @@
|
||||
<span class="nx">render</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
|
||||
<span class="kd">var</span> <span class="nx">items</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">state</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="p">,</span> <span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="p">(</span>
|
||||
<span class="hll"> <span class="o"><</span><span class="nx">div</span> <span class="nx">key</span><span class="o">=</span><span class="p">{</span><span class="nx">i</span><span class="p">}</span> <span class="nx">onClick</span><span class="o">=</span><span class="p">{</span><span class="k">this</span><span class="p">.</span><span class="nx">handleRemove</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">i</span><span class="p">)}</span><span class="o">></span>
|
||||
<span class="hll"> <span class="o"><</span><span class="nx">div</span> <span class="nx">key</span><span class="o">=</span><span class="p">{</span><span class="nx">item</span><span class="p">}</span> <span class="nx">onClick</span><span class="o">=</span><span class="p">{</span><span class="k">this</span><span class="p">.</span><span class="nx">handleRemove</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">i</span><span class="p">)}</span><span class="o">></span>
|
||||
</span><span class="hll"> <span class="p">{</span><span class="nx">item</span><span class="p">}</span>
|
||||
</span><span class="hll"> <span class="o"><</span><span class="err">/div></span>
|
||||
</span> <span class="p">);</span>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -354,7 +354,7 @@
|
||||
<h1>Component API</h1>
|
||||
<div class="subHeader"></div>
|
||||
<h2><a class="anchor" name="reactcomponent"></a>ReactComponent <a class="hash-link" href="#reactcomponent">#</a></h2>
|
||||
<p>Component classses created by <code>createClass()</code> return instances of <code>ReactComponent</code> when called. Most of the time when you're using React you're either creating or consuming these component objects.</p>
|
||||
<p>Component classes created by <code>createClass()</code> return instances of <code>ReactComponent</code> when called. Most of the time when you're using React you're either creating or consuming these component objects.</p>
|
||||
<h3><a class="anchor" name="getdomnode"></a>getDOMNode <a class="hash-link" href="#getdomnode">#</a></h3><div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">DOMElement</span> <span class="nx">getDOMNode</span><span class="p">()</span>
|
||||
</code></pre></div>
|
||||
<p>If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.</p>
|
||||
@@ -413,6 +413,9 @@
|
||||
<p>Calling <code>forceUpdate()</code> will cause <code>render()</code> to be called on the component and its children, but React will still only update the DOM if the markup changes.</p>
|
||||
|
||||
<p>Normally you should try to avoid all uses of <code>forceUpdate()</code> and only read from <code>this.props</code> and <code>this.state</code> in <code>render()</code>. This makes your application much simpler and more efficient.</p>
|
||||
<h3><a class="anchor" name="ismounted"></a>isMounted() <a class="hash-link" href="#ismounted">#</a></h3><div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">bool</span> <span class="nx">isMounted</span><span class="p">()</span>
|
||||
</code></pre></div>
|
||||
<p><code>isMounted()</code> returns true if the component is rendered into the DOM, false otherwise. You can use this method to guard asynchronous calls to <code>setState()</code> or <code>forceUpdate()</code>.</p>
|
||||
|
||||
|
||||
<div class="docs-prevnext">
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -387,7 +387,7 @@
|
||||
<p>Various methods are executed at specific points in a component's lifecycle.</p>
|
||||
<h3><a class="anchor" name="mounting-componentwillmount"></a>Mounting: componentWillMount <a class="hash-link" href="#mounting-componentwillmount">#</a></h3><div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">componentWillMount</span><span class="p">()</span>
|
||||
</code></pre></div>
|
||||
<p>Invoked immediately before rendering occurs. If you call <code>setState</code> within this method, <code>render()</code> will see the updated state and will be executed only once despite the state change.</p>
|
||||
<p>Invoked once, immediately before the initial rendering occurs. If you call <code>setState</code> within this method, <code>render()</code> will see the updated state and will be executed only once despite the state change.</p>
|
||||
<h3><a class="anchor" name="mounting-componentdidmount"></a>Mounting: componentDidMount <a class="hash-link" href="#mounting-componentdidmount">#</a></h3><div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">componentDidMount</span><span class="p">(</span><span class="nx">DOMElement</span> <span class="nx">rootNode</span><span class="p">)</span>
|
||||
</code></pre></div>
|
||||
<p>Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via the <code>rootNode</code> argument or by calling <code>this.getDOMNode()</code>.</p>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+2
-3
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -363,7 +363,6 @@
|
||||
<ul>
|
||||
<li>We've included <a href="/react/docs/tutorial.html">a step-by-step comment box tutorial</a>.</li>
|
||||
<li><a href="/react/downloads.html">The React starter kit</a> includes several examples which you can <a href="https://github.com/facebook/react/tree/master/examples/">view online in our GitHub repository</a>.</li>
|
||||
<li><a href="https://github.com/facebook/react-page">React Page</a> is a simple React project creator to get you up-and-running quickly with React. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.</li>
|
||||
<li><a href="https://github.com/petehunt/react-one-hour-email/commits/master">React one-hour email</a> goes step-by-step from a static HTML mock to an interactive email reader (written in just one hour!)</li>
|
||||
<li><a href="https://github.com/petehunt/rendr-react-template/">Rendr + React app template</a> demonstrates how to use React's server rendering capabilities.</li>
|
||||
</ul>
|
||||
@@ -371,7 +370,7 @@
|
||||
|
||||
<div class="docs-prevnext">
|
||||
|
||||
<a class="docs-prev" href="/react/docs/addons.html">← Prev</a>
|
||||
<a class="docs-prev" href="/react/docs/class-name-manipulation.html">← Prev</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -416,7 +416,7 @@
|
||||
<blockquote>
|
||||
<p>Note:</p>
|
||||
|
||||
<p>The comment parser is very strict right now, in order for it to pick up the <code>@jsx</code> modifier, two conditions are required. The <code>@jsx</code> comment block must be the first comment on the file. The comment must start with <code>/**</code> (<code>/*</code> and <code>//</code> will not work). If the parser can't find the <code>@jsx</code> comment, it will output the file without transforming it.</p>
|
||||
<p>The comment parser is very strict right now; in order for it to pick up the <code>@jsx</code> modifier, two conditions are required. The <code>@jsx</code> comment block must be the first comment on the file. The comment must start with <code>/**</code> (<code>/*</code> and <code>//</code> will not work). If the parser can't find the <code>@jsx</code> comment, it will output the file without transforming it.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>Update your HTML file as below:</p>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -414,7 +414,7 @@ renderB: <span class="nt"><div><span></span>first<span class="nt">&l
|
||||
renderB: <span class="nt"><div><span></span>second<span class="nt"></span><span></span>first<span class="nt"></span></div></span>
|
||||
=> [replaceAttribute textContent 'second'], [insertNode <span class="nt"><span></span>first<span class="nt"></span></span>]
|
||||
</code></pre></div>
|
||||
<p>There are many algorithms that attempt to find the minimum sets of operations to transform a list of elements. <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a> can find the minimum using single element insertion, deletion and substitution in O(n<sup>2</sup>). Even if we were to use Levenshtein, this doesn't find when a node has moved into another position and algorithms to do that have a much worst complexity.</p>
|
||||
<p>There are many algorithms that attempt to find the minimum sets of operations to transform a list of elements. <a href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a> can find the minimum using single element insertion, deletion and substitution in O(n<sup>2</sup>). Even if we were to use Levenshtein, this doesn't find when a node has moved into another position and algorithms to do that have much worse complexity.</p>
|
||||
<h3><a class="anchor" name="keys"></a>Keys <a class="hash-link" href="#keys">#</a></h3>
|
||||
<p>In order to solve this seemingly intractable issue, an optional attribute has been introduced. You can provide for each child a key that is going to be used to do the matching. If you specify a key, React is now able to find insertion, deletion, substitution and moves in O(n) using a hash table.</p>
|
||||
<div class="highlight"><pre><code class="xml language-xml" data-lang="xml">renderA: <span class="nt"><div><span</span> <span class="na">key=</span><span class="s">"first"</span><span class="nt">></span>first<span class="nt"></span></div></span>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -355,7 +355,7 @@
|
||||
<div class="subHeader"></div>
|
||||
<p>When designing interfaces, break down the common design elements (buttons, form fields, layout components, etc) into reusable components with well-defined interfaces. That way, the next time you need to build some UI you can write much less code, which means faster development time, less bugs, and less bytes down the wire.</p>
|
||||
<h2><a class="anchor" name="prop-validation"></a>Prop Validation <a class="hash-link" href="#prop-validation">#</a></h2>
|
||||
<p>As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify <code>propTypes</code>. <code>React.PropTypes</code> exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, an error will be thrown. Here is an example documenting the different validators provided:</p>
|
||||
<p>As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify <code>propTypes</code>. <code>React.PropTypes</code> exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. Note that for performance reasons <code>propTypes</code> is only checked in development mode. Here is an example documenting the different validators provided:</p>
|
||||
<div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="nx">React</span><span class="p">.</span><span class="nx">createClass</span><span class="p">({</span>
|
||||
<span class="nx">propTypes</span><span class="o">:</span> <span class="p">{</span>
|
||||
<span class="c1">// You can declare that a prop is a specific JS primitive. By default, these</span>
|
||||
@@ -375,14 +375,14 @@
|
||||
<span class="c1">// JS's instanceof operator.</span>
|
||||
<span class="nx">someClass</span><span class="o">:</span> <span class="nx">React</span><span class="p">.</span><span class="nx">PropTypes</span><span class="p">.</span><span class="nx">instanceOf</span><span class="p">(</span><span class="nx">SomeClass</span><span class="p">),</span>
|
||||
|
||||
<span class="c1">// You can chain any of the above with isRequired to make sure an error is</span>
|
||||
<span class="c1">// thrown if the prop isn't provided.</span>
|
||||
<span class="c1">// You can chain any of the above with isRequired to make sure a warning is</span>
|
||||
<span class="c1">// shown if the prop isn't provided.</span>
|
||||
<span class="nx">requiredFunc</span><span class="o">:</span> <span class="nx">React</span><span class="p">.</span><span class="nx">PropTypes</span><span class="p">.</span><span class="nx">func</span><span class="p">.</span><span class="nx">isRequired</span>
|
||||
|
||||
<span class="c1">// You can also specify a custom validator.</span>
|
||||
<span class="nx">customProp</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">props</span><span class="p">,</span> <span class="nx">propName</span><span class="p">,</span> <span class="nx">componentName</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="sr">/matchme/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">props</span><span class="p">[</span><span class="nx">propName</span><span class="p">]))</span> <span class="p">{</span>
|
||||
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">'Validation failed!'</span><span class="p">)</span>
|
||||
<span class="nx">console</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">'Validation failed!'</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">},</span>
|
||||
@@ -421,7 +421,7 @@
|
||||
</code></pre></div><h2><a class="anchor" name="mixins"></a>Mixins <a class="hash-link" href="#mixins">#</a></h2>
|
||||
<p>Components are the best way to reuse code in React, but sometimes very different components may share some common functionality. These are sometimes called <a href="http://en.wikipedia.org/wiki/Cross-cutting_concern">cross-cutting concerns</a>. React provides <code>mixins</code> to solve this problem.</p>
|
||||
|
||||
<p>One common use case is a component wanting to update itself on a time interval. It's easy to use <code>setInterval()</code>, but it's important to cancel your interval when you don't need it anymore to save memory. React provides <a href="/react/docs/working-with-the-browser.html">lifecycle methods</a> that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy <code>setInterval()</code> function that will automatically get cleaned up when your component is destroyed.</p>
|
||||
<p>One common use case is a component wanting to update itself on a time interval. It's easy to use <code>setInterval()</code>, but it's important to cancel your interval when you don't need it anymore to save memory. React provides <a href="/react/docs/working-with-the-browser.html#component-lifecycle">lifecycle methods</a> that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy <code>setInterval()</code> function that will automatically get cleaned up when your component is destroyed.</p>
|
||||
<div class="highlight"><pre><code class="javascript language-javascript" data-lang="javascript"><span class="cm">/** @jsx React.DOM */</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">SetIntervalMixin</span> <span class="o">=</span> <span class="p">{</span>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -390,8 +390,6 @@ that support <code>*.tmLanguage</code>.</li>
|
||||
<li>Linting provides accurate line numbers after compiling without sourcemaps.</li>
|
||||
<li>Elements use standard scoping so linters can find usage of out-of-scope components.</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" name="react-page"></a>React Page <a class="hash-link" href="#react-page">#</a></h2>
|
||||
<p>To get started on a new project, you can use <a href="https://github.com/facebook/react-page/">react-page</a>, a complete React project creator. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.</p>
|
||||
|
||||
|
||||
<div class="docs-prevnext">
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -371,7 +371,7 @@
|
||||
<span class="p">[</span><span class="kd">function</span> <span class="nx">callback</span><span class="p">]</span>
|
||||
<span class="p">)</span>
|
||||
</code></pre></div>
|
||||
<p>Render a React component into the DOM in the supplied <code>container</code>.</p>
|
||||
<p>Render a React component into the DOM in the supplied <code>container</code> and return a reference to the component.</p>
|
||||
|
||||
<p>If the React component was previously rendered into <code>container</code>, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.</p>
|
||||
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -354,7 +354,7 @@
|
||||
<h1>Working With the Browser</h1>
|
||||
<div class="subHeader"></div>
|
||||
<p>React provides powerful abstractions that free you from touching the DOM directly in most cases, but sometimes you simply need to access the underlying API, perhaps to work with a third-party library or existing code.</p>
|
||||
<h2><a class="anchor" name="the-mock-dom"></a>The Mock DOM <a class="hash-link" href="#the-mock-dom">#</a></h2>
|
||||
<h2><a class="anchor" name="the-virtual-dom"></a>The Virtual DOM <a class="hash-link" href="#the-virtual-dom">#</a></h2>
|
||||
<p>React is so fast because it never talks to the DOM directly. React maintains a fast in-memory representation of the DOM. <code>render()</code> methods return a <em>description</em> of the DOM, and React can diff this description with the in-memory representation to compute the fastest way to update the browser.</p>
|
||||
|
||||
<p>Additionally, React implements a full synthetic event system such that all event objects are guaranteed to conform to the W3C spec despite browser quirks, and everything bubbles consistently and in a performant way cross-browser. You can even use some HTML5 events in IE8!</p>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
+8
-5
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -107,8 +107,12 @@
|
||||
React components implement a <code>render()</code> method that takes input data and
|
||||
returns what to display. This example uses an XML-like syntax called
|
||||
JSX. Input data that is passed into the component can be accessed by
|
||||
<code>render()</code> via <code>this.props</code>.<br />
|
||||
<strong>JSX is optional and not required to use React.</strong>
|
||||
<code>render()</code> via <code>this.props</code>.
|
||||
</p>
|
||||
<p>
|
||||
<strong>JSX is optional and not required to use React.</strong> Try
|
||||
clicking on "Compiled JS" to see the raw JavaScript code produced by
|
||||
the JSX compiler.
|
||||
</p>
|
||||
<div id="helloExample"></div>
|
||||
</div>
|
||||
@@ -118,8 +122,7 @@
|
||||
In addition to taking input data (accessed via <code>this.props</code>), a
|
||||
component can maintain internal state data (accessed via <code>this.state</code>).
|
||||
When a component's state data changes, the rendered markup will be
|
||||
updated by re-invoking <code>render()</code>.<br />
|
||||
<strong>This example demonstrates use of React without JSX.</strong>
|
||||
updated by re-invoking <code>render()</code>.
|
||||
</p>
|
||||
<div id="timerExample"></div>
|
||||
</div>
|
||||
|
||||
+446
@@ -0,0 +1,446 @@
|
||||
// Copyright 2009-2012 by contributors, MIT License
|
||||
// vim: ts=4 sts=4 sw=4 expandtab
|
||||
|
||||
//Add semicolon to prevent IIFE from being passed as argument to concated code.
|
||||
;
|
||||
// Module systems magic dance
|
||||
(function (definition) {
|
||||
// RequireJS
|
||||
if (typeof define == "function") {
|
||||
define(definition);
|
||||
// YUI3
|
||||
} else if (typeof YUI == "function") {
|
||||
YUI.add("es5-sham", definition);
|
||||
// CommonJS and <script>
|
||||
} else {
|
||||
definition();
|
||||
}
|
||||
})(function () {
|
||||
|
||||
|
||||
var call = Function.prototype.call;
|
||||
var prototypeOfObject = Object.prototype;
|
||||
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
||||
|
||||
// If JS engine supports accessors creating shortcuts.
|
||||
var defineGetter;
|
||||
var defineSetter;
|
||||
var lookupGetter;
|
||||
var lookupSetter;
|
||||
var supportsAccessors;
|
||||
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
|
||||
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
|
||||
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
|
||||
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
|
||||
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
|
||||
}
|
||||
|
||||
// ES5 15.2.3.2
|
||||
// http://es5.github.com/#x15.2.3.2
|
||||
if (!Object.getPrototypeOf) {
|
||||
// https://github.com/es-shims/es5-shim/issues#issue/2
|
||||
// http://ejohn.org/blog/objectgetprototypeof/
|
||||
// recommended by fschaefer on github
|
||||
Object.getPrototypeOf = function getPrototypeOf(object) {
|
||||
return object.__proto__ || (
|
||||
object.constructor
|
||||
? object.constructor.prototype
|
||||
: prototypeOfObject
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
//ES5 15.2.3.3
|
||||
//http://es5.github.com/#x15.2.3.3
|
||||
|
||||
function doesGetOwnPropertyDescriptorWork(object) {
|
||||
try {
|
||||
object.sentinel = 0;
|
||||
return Object.getOwnPropertyDescriptor(
|
||||
object,
|
||||
"sentinel"
|
||||
).value === 0;
|
||||
} catch (exception) {
|
||||
// returns falsy
|
||||
}
|
||||
}
|
||||
|
||||
//check whether getOwnPropertyDescriptor works if it's given. Otherwise,
|
||||
//shim partially.
|
||||
if (Object.defineProperty) {
|
||||
var getOwnPropertyDescriptorWorksOnObject =
|
||||
doesGetOwnPropertyDescriptorWork({});
|
||||
var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
|
||||
doesGetOwnPropertyDescriptorWork(document.createElement("div"));
|
||||
if (!getOwnPropertyDescriptorWorksOnDom ||
|
||||
!getOwnPropertyDescriptorWorksOnObject
|
||||
) {
|
||||
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
|
||||
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
|
||||
|
||||
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
|
||||
if ((typeof object != "object" && typeof object != "function") || object === null) {
|
||||
throw new TypeError(ERR_NON_OBJECT + object);
|
||||
}
|
||||
|
||||
// make a valiant attempt to use the real getOwnPropertyDescriptor
|
||||
// for I8's DOM elements.
|
||||
if (getOwnPropertyDescriptorFallback) {
|
||||
try {
|
||||
return getOwnPropertyDescriptorFallback.call(Object, object, property);
|
||||
} catch (exception) {
|
||||
// try the shim if the real one doesn't work
|
||||
}
|
||||
}
|
||||
|
||||
// If object does not owns property return undefined immediately.
|
||||
if (!owns(object, property)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If object has a property then it's for sure both `enumerable` and
|
||||
// `configurable`.
|
||||
var descriptor = { enumerable: true, configurable: true };
|
||||
|
||||
// If JS engine supports accessor properties then property may be a
|
||||
// getter or setter.
|
||||
if (supportsAccessors) {
|
||||
// Unfortunately `__lookupGetter__` will return a getter even
|
||||
// if object has own non getter property along with a same named
|
||||
// inherited getter. To avoid misbehavior we temporary remove
|
||||
// `__proto__` so that `__lookupGetter__` will return getter only
|
||||
// if it's owned by an object.
|
||||
var prototype = object.__proto__;
|
||||
object.__proto__ = prototypeOfObject;
|
||||
|
||||
var getter = lookupGetter(object, property);
|
||||
var setter = lookupSetter(object, property);
|
||||
|
||||
// Once we have getter and setter we can put values back.
|
||||
object.__proto__ = prototype;
|
||||
|
||||
if (getter || setter) {
|
||||
if (getter) {
|
||||
descriptor.get = getter;
|
||||
}
|
||||
if (setter) {
|
||||
descriptor.set = setter;
|
||||
}
|
||||
// If it was accessor property we're done and return here
|
||||
// in order to avoid adding `value` to the descriptor.
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far we know that object has an own property that is
|
||||
// not an accessor so we set it as a value and return descriptor.
|
||||
descriptor.value = object[property];
|
||||
descriptor.writable = true;
|
||||
return descriptor;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.4
|
||||
// http://es5.github.com/#x15.2.3.4
|
||||
if (!Object.getOwnPropertyNames) {
|
||||
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
|
||||
return Object.keys(object);
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.5
|
||||
// http://es5.github.com/#x15.2.3.5
|
||||
if (!Object.create) {
|
||||
|
||||
// Contributed by Brandon Benvie, October, 2012
|
||||
var createEmpty;
|
||||
var supportsProto = Object.prototype.__proto__ === null;
|
||||
if (supportsProto || typeof document == 'undefined') {
|
||||
createEmpty = function () {
|
||||
return { "__proto__": null };
|
||||
};
|
||||
} else {
|
||||
// In old IE __proto__ can't be used to manually set `null`, nor does
|
||||
// any other method exist to make an object that inherits from nothing,
|
||||
// aside from Object.prototype itself. Instead, create a new global
|
||||
// object and *steal* its Object.prototype and strip it bare. This is
|
||||
// used as the prototype to create nullary objects.
|
||||
createEmpty = function () {
|
||||
var iframe = document.createElement('iframe');
|
||||
var parent = document.body || document.documentElement;
|
||||
iframe.style.display = 'none';
|
||||
parent.appendChild(iframe);
|
||||
iframe.src = 'javascript:';
|
||||
var empty = iframe.contentWindow.Object.prototype;
|
||||
parent.removeChild(iframe);
|
||||
iframe = null;
|
||||
delete empty.constructor;
|
||||
delete empty.hasOwnProperty;
|
||||
delete empty.propertyIsEnumerable;
|
||||
delete empty.isPrototypeOf;
|
||||
delete empty.toLocaleString;
|
||||
delete empty.toString;
|
||||
delete empty.valueOf;
|
||||
empty.__proto__ = null;
|
||||
|
||||
function Empty() {}
|
||||
Empty.prototype = empty;
|
||||
// short-circuit future calls
|
||||
createEmpty = function () {
|
||||
return new Empty();
|
||||
};
|
||||
return new Empty();
|
||||
};
|
||||
}
|
||||
|
||||
Object.create = function create(prototype, properties) {
|
||||
|
||||
var object;
|
||||
function Type() {} // An empty constructor.
|
||||
|
||||
if (prototype === null) {
|
||||
object = createEmpty();
|
||||
} else {
|
||||
if (typeof prototype !== "object" && typeof prototype !== "function") {
|
||||
// In the native implementation `parent` can be `null`
|
||||
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
|
||||
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
|
||||
// like they are in modern browsers. Using `Object.create` on DOM elements
|
||||
// is...err...probably inappropriate, but the native version allows for it.
|
||||
throw new TypeError("Object prototype may only be an Object or null"); // same msg as Chrome
|
||||
}
|
||||
Type.prototype = prototype;
|
||||
object = new Type();
|
||||
// IE has no built-in implementation of `Object.getPrototypeOf`
|
||||
// neither `__proto__`, but this manually setting `__proto__` will
|
||||
// guarantee that `Object.getPrototypeOf` will work as expected with
|
||||
// objects created using `Object.create`
|
||||
object.__proto__ = prototype;
|
||||
}
|
||||
|
||||
if (properties !== void 0) {
|
||||
Object.defineProperties(object, properties);
|
||||
}
|
||||
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.6
|
||||
// http://es5.github.com/#x15.2.3.6
|
||||
|
||||
// Patch for WebKit and IE8 standard mode
|
||||
// Designed by hax <hax.github.com>
|
||||
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
|
||||
// IE8 Reference:
|
||||
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
|
||||
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
|
||||
// WebKit Bugs:
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=36423
|
||||
|
||||
function doesDefinePropertyWork(object) {
|
||||
try {
|
||||
Object.defineProperty(object, "sentinel", {});
|
||||
return "sentinel" in object;
|
||||
} catch (exception) {
|
||||
// returns falsy
|
||||
}
|
||||
}
|
||||
|
||||
// check whether defineProperty works if it's given. Otherwise,
|
||||
// shim partially.
|
||||
if (Object.defineProperty) {
|
||||
var definePropertyWorksOnObject = doesDefinePropertyWork({});
|
||||
var definePropertyWorksOnDom = typeof document == "undefined" ||
|
||||
doesDefinePropertyWork(document.createElement("div"));
|
||||
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
|
||||
var definePropertyFallback = Object.defineProperty,
|
||||
definePropertiesFallback = Object.defineProperties;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Object.defineProperty || definePropertyFallback) {
|
||||
var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
|
||||
var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
|
||||
var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
|
||||
"on this javascript engine";
|
||||
|
||||
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
||||
if ((typeof object != "object" && typeof object != "function") || object === null) {
|
||||
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
|
||||
}
|
||||
if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) {
|
||||
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
|
||||
}
|
||||
// make a valiant attempt to use the real defineProperty
|
||||
// for I8's DOM elements.
|
||||
if (definePropertyFallback) {
|
||||
try {
|
||||
return definePropertyFallback.call(Object, object, property, descriptor);
|
||||
} catch (exception) {
|
||||
// try the shim if the real one doesn't work
|
||||
}
|
||||
}
|
||||
|
||||
// If it's a data property.
|
||||
if (owns(descriptor, "value")) {
|
||||
// fail silently if "writable", "enumerable", or "configurable"
|
||||
// are requested but not supported
|
||||
/*
|
||||
// alternate approach:
|
||||
if ( // can't implement these features; allow false but not true
|
||||
!(owns(descriptor, "writable") ? descriptor.writable : true) ||
|
||||
!(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
|
||||
!(owns(descriptor, "configurable") ? descriptor.configurable : true)
|
||||
)
|
||||
throw new RangeError(
|
||||
"This implementation of Object.defineProperty does not " +
|
||||
"support configurable, enumerable, or writable."
|
||||
);
|
||||
*/
|
||||
|
||||
if (supportsAccessors && (lookupGetter(object, property) ||
|
||||
lookupSetter(object, property)))
|
||||
{
|
||||
// As accessors are supported only on engines implementing
|
||||
// `__proto__` we can safely override `__proto__` while defining
|
||||
// a property to make sure that we don't hit an inherited
|
||||
// accessor.
|
||||
var prototype = object.__proto__;
|
||||
object.__proto__ = prototypeOfObject;
|
||||
// Deleting a property anyway since getter / setter may be
|
||||
// defined on object itself.
|
||||
delete object[property];
|
||||
object[property] = descriptor.value;
|
||||
// Setting original `__proto__` back now.
|
||||
object.__proto__ = prototype;
|
||||
} else {
|
||||
object[property] = descriptor.value;
|
||||
}
|
||||
} else {
|
||||
if (!supportsAccessors) {
|
||||
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
||||
}
|
||||
// If we got that far then getters and setters can be defined !!
|
||||
if (owns(descriptor, "get")) {
|
||||
defineGetter(object, property, descriptor.get);
|
||||
}
|
||||
if (owns(descriptor, "set")) {
|
||||
defineSetter(object, property, descriptor.set);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.7
|
||||
// http://es5.github.com/#x15.2.3.7
|
||||
if (!Object.defineProperties || definePropertiesFallback) {
|
||||
Object.defineProperties = function defineProperties(object, properties) {
|
||||
// make a valiant attempt to use the real defineProperties
|
||||
if (definePropertiesFallback) {
|
||||
try {
|
||||
return definePropertiesFallback.call(Object, object, properties);
|
||||
} catch (exception) {
|
||||
// try the shim if the real one doesn't work
|
||||
}
|
||||
}
|
||||
|
||||
for (var property in properties) {
|
||||
if (owns(properties, property) && property != "__proto__") {
|
||||
Object.defineProperty(object, property, properties[property]);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.8
|
||||
// http://es5.github.com/#x15.2.3.8
|
||||
if (!Object.seal) {
|
||||
Object.seal = function seal(object) {
|
||||
// this is misleading and breaks feature-detection, but
|
||||
// allows "securable" code to "gracefully" degrade to working
|
||||
// but insecure code.
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.9
|
||||
// http://es5.github.com/#x15.2.3.9
|
||||
if (!Object.freeze) {
|
||||
Object.freeze = function freeze(object) {
|
||||
// this is misleading and breaks feature-detection, but
|
||||
// allows "securable" code to "gracefully" degrade to working
|
||||
// but insecure code.
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// detect a Rhino bug and patch it
|
||||
try {
|
||||
Object.freeze(function () {});
|
||||
} catch (exception) {
|
||||
Object.freeze = (function freeze(freezeObject) {
|
||||
return function freeze(object) {
|
||||
if (typeof object == "function") {
|
||||
return object;
|
||||
} else {
|
||||
return freezeObject(object);
|
||||
}
|
||||
};
|
||||
})(Object.freeze);
|
||||
}
|
||||
|
||||
// ES5 15.2.3.10
|
||||
// http://es5.github.com/#x15.2.3.10
|
||||
if (!Object.preventExtensions) {
|
||||
Object.preventExtensions = function preventExtensions(object) {
|
||||
// this is misleading and breaks feature-detection, but
|
||||
// allows "securable" code to "gracefully" degrade to working
|
||||
// but insecure code.
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.11
|
||||
// http://es5.github.com/#x15.2.3.11
|
||||
if (!Object.isSealed) {
|
||||
Object.isSealed = function isSealed(object) {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.12
|
||||
// http://es5.github.com/#x15.2.3.12
|
||||
if (!Object.isFrozen) {
|
||||
Object.isFrozen = function isFrozen(object) {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// ES5 15.2.3.13
|
||||
// http://es5.github.com/#x15.2.3.13
|
||||
if (!Object.isExtensible) {
|
||||
Object.isExtensible = function isExtensible(object) {
|
||||
// 1. If Type(O) is not Object throw a TypeError exception.
|
||||
if (Object(object) !== object) {
|
||||
throw new TypeError(); // TODO message
|
||||
}
|
||||
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
|
||||
var name = '';
|
||||
while (owns(object, name)) {
|
||||
name += '?';
|
||||
}
|
||||
object[name] = true;
|
||||
var returnValue = owns(object, name);
|
||||
delete object[name];
|
||||
return returnValue;
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
+1360
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ var HELLO_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var HelloMessage = React.createClass({\n\
|
||||
render: function() {\n\
|
||||
return <div>{'Hello ' + this.props.name}</div>;\n\
|
||||
return <div>Hello {this.props.name}</div>;\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
var TIMER_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var Timer = React.createClass({\n\
|
||||
getInitialState: function() {\n\
|
||||
return {secondsElapsed: 0};\n\
|
||||
@@ -17,13 +18,13 @@ var Timer = React.createClass({\n\
|
||||
clearInterval(this.interval);\n\
|
||||
},\n\
|
||||
render: function() {\n\
|
||||
return React.DOM.div({},\n\
|
||||
'Seconds Elapsed: ', this.state.secondsElapsed\n\
|
||||
return (\n\
|
||||
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>\n\
|
||||
);\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
React.renderComponent(Timer({}), mountNode);\
|
||||
React.renderComponent(<Timer />, mountNode);\
|
||||
";
|
||||
|
||||
React.renderComponent(
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ var HELLO_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var HelloMessage = React.createClass({\n\
|
||||
render: function() {\n\
|
||||
return <div>{'Hello ' + this.props.name}</div>;\n\
|
||||
return <div>Hello {this.props.name}</div>;\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
|
||||
+80
-38
@@ -14,27 +14,33 @@ var IS_MOBILE = (
|
||||
);
|
||||
|
||||
var CodeMirrorEditor = React.createClass({displayName: 'CodeMirrorEditor',
|
||||
componentDidMount: function(root) {
|
||||
if (IS_MOBILE) {
|
||||
return;
|
||||
}
|
||||
componentDidMount: function() {
|
||||
if (IS_MOBILE) return;
|
||||
|
||||
this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), {
|
||||
mode: 'javascript',
|
||||
lineNumbers: false,
|
||||
lineWrapping: true,
|
||||
smartIndent: false, // javascript mode does bad things with jsx indents
|
||||
matchBrackets: true,
|
||||
theme: 'solarized-light',
|
||||
readOnly: this.props.readOnly
|
||||
});
|
||||
this.editor.on('change', this.onChange);
|
||||
this.onChange();
|
||||
this.editor.on('change', this.handleChange);
|
||||
},
|
||||
onChange: function() {
|
||||
if (this.props.onChange) {
|
||||
var content = this.editor.getValue();
|
||||
this.props.onChange(content);
|
||||
|
||||
componentDidUpdate: function() {
|
||||
if (this.props.readOnly) {
|
||||
this.editor.setValue(this.props.codeText);
|
||||
}
|
||||
},
|
||||
|
||||
handleChange: function() {
|
||||
if (!this.props.readOnly) {
|
||||
this.props.onChange && this.props.onChange(this.editor.getValue());
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
// wrap in a div to fully contain CodeMirror
|
||||
var editor;
|
||||
@@ -46,7 +52,7 @@ var CodeMirrorEditor = React.createClass({displayName: 'CodeMirrorEditor',
|
||||
}
|
||||
|
||||
return (
|
||||
React.DOM.div( {className:this.props.className},
|
||||
React.DOM.div( {style:this.props.style, className:this.props.className},
|
||||
editor
|
||||
)
|
||||
);
|
||||
@@ -67,7 +73,7 @@ var selfCleaningTimeout = {
|
||||
var ReactPlayground = React.createClass({displayName: 'ReactPlayground',
|
||||
mixins: [selfCleaningTimeout],
|
||||
|
||||
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
|
||||
MODES: {JSX: 'JSX', JS: 'JS'}, //keyMirror({JSX: true, JS: true}),
|
||||
|
||||
propTypes: {
|
||||
codeText: React.PropTypes.string.isRequired,
|
||||
@@ -84,15 +90,19 @@ var ReactPlayground = React.createClass({displayName: 'ReactPlayground',
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {mode: this.MODES.XJS, code: this.props.codeText};
|
||||
return {
|
||||
mode: this.MODES.JSX,
|
||||
code: this.props.codeText,
|
||||
};
|
||||
},
|
||||
|
||||
bindState: function(name) {
|
||||
return function(value) {
|
||||
var newState = {};
|
||||
newState[name] = value;
|
||||
this.setState(newState);
|
||||
}.bind(this);
|
||||
handleCodeChange: function(value) {
|
||||
this.setState({code: value});
|
||||
this.executeCode();
|
||||
},
|
||||
|
||||
handleCodeModeSwitch: function(mode) {
|
||||
this.setState({mode: mode});
|
||||
},
|
||||
|
||||
compileCode: function() {
|
||||
@@ -100,25 +110,50 @@ var ReactPlayground = React.createClass({displayName: 'ReactPlayground',
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var content;
|
||||
if (this.state.mode === this.MODES.XJS) {
|
||||
content =
|
||||
CodeMirrorEditor(
|
||||
{onChange:this.bindState('code'),
|
||||
className:"playgroundStage",
|
||||
codeText:this.state.code}
|
||||
);
|
||||
} else if (this.state.mode === this.MODES.JS) {
|
||||
content =
|
||||
React.DOM.div( {className:"playgroundJS playgroundStage"},
|
||||
this.compileCode()
|
||||
);
|
||||
}
|
||||
var isJS = this.state.mode === this.MODES.JS;
|
||||
var compiledCode = '';
|
||||
try {
|
||||
compiledCode = this.compileCode();
|
||||
} catch (err) {}
|
||||
|
||||
var jsContent =
|
||||
CodeMirrorEditor(
|
||||
{key:"js",
|
||||
className:"playgroundStage CodeMirror-readonly",
|
||||
onChange:this.handleCodeChange,
|
||||
codeText:compiledCode,
|
||||
readOnly:true}
|
||||
);
|
||||
|
||||
var jsxContent =
|
||||
CodeMirrorEditor(
|
||||
{key:"jsx",
|
||||
onChange:this.handleCodeChange,
|
||||
className:"playgroundStage",
|
||||
codeText:this.state.code}
|
||||
);
|
||||
|
||||
var JSXTabClassName =
|
||||
'playground-tab' + (isJS ? '' : ' playground-tab-active');
|
||||
var JSTabClassName =
|
||||
'playground-tab' + (isJS ? ' playground-tab-active' : '');
|
||||
|
||||
return (
|
||||
React.DOM.div( {className:"playground"},
|
||||
React.DOM.div(null,
|
||||
React.DOM.div(
|
||||
{className:JSXTabClassName,
|
||||
onClick:this.handleCodeModeSwitch.bind(this, this.MODES.JSX)},
|
||||
" Live JSX Editor "
|
||||
),
|
||||
React.DOM.div(
|
||||
{className:JSTabClassName,
|
||||
onClick:this.handleCodeModeSwitch.bind(this, this.MODES.JS)},
|
||||
" Compiled JS "
|
||||
)
|
||||
),
|
||||
React.DOM.div( {className:"playgroundCode"},
|
||||
content
|
||||
isJS ? jsContent : jsxContent
|
||||
),
|
||||
React.DOM.div( {className:"playgroundPreview"},
|
||||
React.DOM.div( {ref:"mount"} )
|
||||
@@ -126,12 +161,19 @@ var ReactPlayground = React.createClass({displayName: 'ReactPlayground',
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
this.executeCode();
|
||||
},
|
||||
componentDidUpdate: function() {
|
||||
this.executeCode();
|
||||
|
||||
componentWillUpdate: function(nextProps, nextState) {
|
||||
// execute code only when the state's not being updated by switching tab
|
||||
// this avoids re-displaying the error, which comes after a certain delay
|
||||
if (this.state.code !== nextState.code) {
|
||||
this.executeCode();
|
||||
}
|
||||
},
|
||||
|
||||
executeCode: function() {
|
||||
var mountNode = this.refs.mount.getDOMNode();
|
||||
|
||||
@@ -149,10 +191,10 @@ var ReactPlayground = React.createClass({displayName: 'ReactPlayground',
|
||||
} else {
|
||||
eval(compiledCode);
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (err) {
|
||||
this.setTimeout(function() {
|
||||
React.renderComponent(
|
||||
React.DOM.div( {className:"playgroundError"}, e.toString()),
|
||||
React.DOM.div( {className:"playgroundError"}, err.toString()),
|
||||
mountNode
|
||||
);
|
||||
}, 500);
|
||||
|
||||
Vendored
+5
-4
File diff suppressed because one or more lines are too long
+1301
-1301
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
@@ -61,7 +61,7 @@
|
||||
<h1>JSX Compiler</h1>
|
||||
<p>
|
||||
This tool demonstrates how <a href="/react/docs/jsx-in-depth.html">JSX syntax</a>
|
||||
is desguared into native JavaScript.
|
||||
is desugared into native JavaScript.
|
||||
</p>
|
||||
<div id="jsxCompiler"></div>
|
||||
<script type="text/javascript" src="js/jsx-compiler.js"></script>
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE]><![endif]-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>React | References to Components</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta property="og:title" content="React | References to Components" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="http://facebook.github.io/react/tips/references-to-components.html" />
|
||||
<meta property="og:image" content="http://facebook.github.io/react/img/logo_og.png" />
|
||||
<meta property="og:description" content="A JavaScript library for building user interfaces" />
|
||||
<meta property="fb:app_id" content="623268441017527" />
|
||||
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
<!--[if lte IE 8]>
|
||||
<script type="text/javascript" src="/react/js/html5shiv.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/es5-shim.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="/react/js/codemirror.js"></script>
|
||||
<script type="text/javascript" src="/react/js/javascript.js"></script>
|
||||
<script type="text/javascript" src="/react/js/react.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>
|
||||
<script type="text/javascript" src="/react/js/live_editor.js"></script>
|
||||
<script type="text/javascript" src="/react/js/showdown.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="nav-main">
|
||||
<div class="wrap">
|
||||
<a class="nav-home" href="/react/index.html">
|
||||
<img class="nav-logo" alt="" src="/react/img/logo_small.png" width="38" height="38">
|
||||
React
|
||||
</a>
|
||||
<ul class="nav-site">
|
||||
<li><a href="/react/docs/getting-started.html">docs</a></li>
|
||||
<li><a href="/react/support.html">support</a></li>
|
||||
<li><a href="/react/downloads.html">download</a></li>
|
||||
<li><a href="/react/blog/">blog</a></li>
|
||||
<li><a href="http://github.com/facebook/react">github</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<section class="content wrap documentationContent">
|
||||
<div class="nav-docs">
|
||||
<!-- Docs Nav -->
|
||||
|
||||
<div class="nav-docs-section">
|
||||
<h3>Quick Start</h3>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/getting-started.html">
|
||||
Getting Started
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/tutorial.html">
|
||||
Tutorial
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/videos.html">
|
||||
Videos
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="nav-docs-section">
|
||||
<h3>Guides</h3>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/why-react.html">
|
||||
Why React?
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/displaying-data.html">
|
||||
Displaying Data
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/jsx-in-depth.html">
|
||||
JSX in Depth
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/jsx-gotchas.html">
|
||||
JSX Gotchas
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/interactivity-and-dynamic-uis.html">
|
||||
Interactivity and Dynamic UIs
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/multiple-components.html">
|
||||
Multiple Components
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/reusable-components.html">
|
||||
Reusable Components
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/forms.html">
|
||||
Forms
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/working-with-the-browser.html">
|
||||
Working With the Browser
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/more-about-refs.html">
|
||||
More About Refs
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/tooling-integration.html">
|
||||
Tooling Integration
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/addons.html">
|
||||
Add-Ons
|
||||
</a>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/animation.html">
|
||||
Animation
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/two-way-binding-helpers.html">
|
||||
Two-Way Binding Helpers
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/class-name-manipulation.html">
|
||||
Class Name Manipulation
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/examples.html">
|
||||
Examples
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="nav-docs-section">
|
||||
<h3>Reference</h3>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/top-level-api.html">
|
||||
Top-Level API
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/component-api.html">
|
||||
Component API
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/component-specs.html">
|
||||
Component Specs and Lifecycle
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/tags-and-attributes.html">
|
||||
Supported Tags and Attributes
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/events.html">
|
||||
Event System
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/dom-differences.html">
|
||||
DOM Differences
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/special-non-dom-attributes.html">
|
||||
Special Non-DOM attributes
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/docs/reconciliation.html">
|
||||
Reconciliation
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Tips Nav -->
|
||||
|
||||
<div class="nav-docs-section">
|
||||
<h3>Tips</h3>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/introduction.html">Introduction</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/inline-styles.html">Inline Styles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/if-else-in-JSX.html">If-Else in JSX</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/self-closing-tag.html">Self-Closing Tag</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/maximum-number-of-jsx-root-nodes.html">Maximum Number of JSX Root Nodes</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/style-props-value-px.html">Shorthand for Specifying Pixel Values in style props</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/children-props-type.html">Type of the Children props</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/controlled-input-null-value.html">Value of null for Controlled Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/componentWillReceiveProps-not-triggered-after-mounting.html">componentWillReceiveProps Not Triggered After Mounting</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/props-in-getInitialState-as-anti-pattern.html">Props in getInitialState Is an Anti-Pattern</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/dom-event-listeners.html">DOM Event Listeners in a Component</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/initial-ajax.html">Load Initial Data via AJAX</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/false-in-jsx.html">False in JSX</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/communicate-between-components.html">Communicate Between Components</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/react/tips/expose-component-functions.html">Expose Component Functions</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="inner-content">
|
||||
<h1>References to Components</h1>
|
||||
<div class="subHeader"></div>
|
||||
<p>If you're using React components in a larger non-React application or transitioning your code to React, you may need to keep references to components. <code>React.renderComponent</code> returns a reference to the mounted component:</p>
|
||||
<div class="highlight"><pre><code class="js language-js" data-lang="js"><span class="cm">/** @jsx React.DOM */</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">myComponent</span> <span class="o">=</span> <span class="nx">React</span><span class="p">.</span><span class="nx">renderComponent</span><span class="p">(</span><span class="o"><</span><span class="nx">MyComponent</span> <span class="o">/></span><span class="p">,</span> <span class="nx">myContainer</span><span class="p">);</span>
|
||||
</code></pre></div>
|
||||
<p>If you pass a variable to 'React.renderComponent`, it's not guaranteed that the component passed in will be the one that's mounted. In cases where you construct a component before mounting it, be sure to reassign your variable:</p>
|
||||
<div class="highlight"><pre><code class="js language-js" data-lang="js"><span class="cm">/** @jsx React.DOM */</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">myComponent</span> <span class="o">=</span> <span class="o"><</span><span class="nx">MyComponent</span> <span class="o">/></span><span class="p">;</span>
|
||||
|
||||
<span class="c1">// Some code here...</span>
|
||||
|
||||
<span class="nx">myComponent</span> <span class="o">=</span> <span class="nx">React</span><span class="p">.</span><span class="nx">renderComponent</span><span class="p">(</span><span class="nx">myComponent</span><span class="p">,</span> <span class="nx">myContainer</span><span class="p">);</span>
|
||||
</code></pre></div>
|
||||
<blockquote>
|
||||
<p>Note:</p>
|
||||
|
||||
<p>This should only ever be used at the top level. Inside components, let your <code>props</code> and <code>state</code> handle communication with child components, and only reference components via <code>ref</code>s.</p>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<div class="docs-prevnext">
|
||||
|
||||
<a class="docs-prev" href="/react/tips/expose-component-functions.html">← Prev</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="http://facebook.github.io/react/tips/references-to-components.html"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<footer class="wrap">
|
||||
<div class="left">A Facebook & Instagram collaboration.</div>
|
||||
<div class="right">© 2014 Facebook Inc.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<div id="fb-root"></div>
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-41298772-1', 'facebook.github.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
|
||||
|
||||
(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=623268441017527";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="React" href="http://facebook.github.io/react/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
Reference in New Issue
Block a user