mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
update website
This commit is contained in:
@@ -34,7 +34,7 @@ React<span class="token punctuation">.</span>AppRegistry<span class="token punct
|
||||
</span>
|
||||
@interface <span class="token class-name">ViewController</span> <span class="token punctuation">(</span><span class="token punctuation">)</span>
|
||||
@property <span class="token punctuation">(</span>weak<span class="token punctuation">,</span> nonatomic<span class="token punctuation">)</span> IBOutlet ReactView <span class="token operator">*</span>reactView<span class="token punctuation">;</span>
|
||||
@end</div><p>Here I disabled <strong>AutoLayout</strong> for simplicity. In real production world, you should turn on AutoLayout and setup constraints by yourself.</p><h2><a class="anchor" name="add-rctrootview-to-container-view"></a>Add RCTRootView To Container View <a class="hash-link" href="#add-rctrootview-to-container-view">#</a></h2><p>Ready for the most interesting part? Now we shall create the <code>RCTRootView</code>, where your React Native app lives in.</p><p>In <code>ReactView.m</code>, we need to first initiate <code>RCTRootView</code> with the URI of your <code>index.ios.bundle</code>. <code>index.ios.bundle</code> will be created by packager and served by React Native server, which will be discussed later on.</p><div class="prism language-javascript">NSURL <span class="token operator">*</span>jsCodeLocation <span class="token operator">=</span> <span class="token punctuation">[</span>NSURL URLWithString<span class="token punctuation">:</span>@<span class="token string">"http://localhost:8081/index.ios.bundle"</span><span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">
|
||||
@end</div><p>Here I disabled <strong>AutoLayout</strong> for simplicity. In real production world, you should turn on AutoLayout and setup constraints by yourself.</p><h2><a class="anchor" name="add-rctrootview-to-container-view"></a>Add RCTRootView To Container View <a class="hash-link" href="#add-rctrootview-to-container-view">#</a></h2><p>Ready for the most interesting part? Now we shall create the <code>RCTRootView</code>, where your React Native app lives.</p><p>In <code>ReactView.m</code>, we need to first initiate <code>RCTRootView</code> with the URI of your <code>index.ios.bundle</code>. <code>index.ios.bundle</code> will be created by packager and served by React Native server, which will be discussed later on.</p><div class="prism language-javascript">NSURL <span class="token operator">*</span>jsCodeLocation <span class="token operator">=</span> <span class="token punctuation">[</span>NSURL URLWithString<span class="token punctuation">:</span>@<span class="token string">"http://localhost:8081/index.ios.bundle"</span><span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true">
|
||||
// For production use, this `NSURL` could instead point to a pre-bundled file on disk:
|
||||
</span><span class="token comment" spellcheck="true">//
|
||||
</span><span class="token comment" spellcheck="true">// NSURL *jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||
|
||||
Reference in New Issue
Block a user