mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
@@ -134,13 +134,15 @@ export class Hello extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
this.state = {
|
||||
enthusiasmLevel: props.enthusiasmLevel || 1
|
||||
enthusiasmLevel: props.enthusiasmLevel || 1,
|
||||
};
|
||||
}
|
||||
|
||||
onIncrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel + 1 });
|
||||
onDecrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel - 1 });
|
||||
getExclamationMarks = (numChars: number) => Array(numChars + 1).join("!")
|
||||
onIncrement = () =>
|
||||
this.setState({enthusiasmLevel: this.state.enthusiasmLevel + 1});
|
||||
onDecrement = () =>
|
||||
this.setState({enthusiasmLevel: this.state.enthusiasmLevel - 1});
|
||||
getExclamationMarks = (numChars: number) => Array(numChars + 1).join('!');
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
+6
-4
@@ -134,13 +134,15 @@ export class Hello extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
this.state = {
|
||||
enthusiasmLevel: props.enthusiasmLevel || 1
|
||||
enthusiasmLevel: props.enthusiasmLevel || 1,
|
||||
};
|
||||
}
|
||||
|
||||
onIncrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel + 1 });
|
||||
onDecrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel - 1 });
|
||||
getExclamationMarks = (numChars: number) => Array(numChars + 1).join("!")
|
||||
onIncrement = () =>
|
||||
this.setState({enthusiasmLevel: this.state.enthusiasmLevel + 1});
|
||||
onDecrement = () =>
|
||||
this.setState({enthusiasmLevel: this.state.enthusiasmLevel - 1});
|
||||
getExclamationMarks = (numChars: number) => Array(numChars + 1).join('!');
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
+13
-10
@@ -27,16 +27,19 @@
|
||||
</ul>
|
||||
<p>If you don't need section support and want a simpler interface, use <a href="/react-native/docs/next/flatlist.html"><code><FlatList></code></a>.</p>
|
||||
<p>Simple Examples:</p>
|
||||
<pre><code class="hljs css javascript"><span class="hljs-comment">// Example 1 (Homogeneous Rendering) </span>
|
||||
<SectionList
|
||||
renderItem={({ item, index, section }) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{index}</span>></span>{item}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
renderSectionHeader={({ <span class="hljs-attr">section</span>: { title } }) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">fontWeight:</span> '<span class="hljs-attr">bold</span>' }}></span>{title}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
sections={[
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title1'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item1'</span>, <span class="hljs-string">'item2'</span>] },
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title2'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item3'</span>, <span class="hljs-string">'item4'</span>] },
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title3'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item5'</span>, <span class="hljs-string">'item6'</span>] },
|
||||
]}
|
||||
keyExtractor={(item, index) => item + index} />
|
||||
<pre><code class="hljs css javascript"><span class="hljs-comment">// Example 1 (Homogeneous Rendering)</span>
|
||||
<SectionList
|
||||
renderItem={({item, index, section}) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{index}</span>></span>{item}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
renderSectionHeader={({<span class="hljs-attr">section</span>: {title}}) => (
|
||||
<span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{fontWeight:</span> '<span class="hljs-attr">bold</span>'}}></span>{title}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>
|
||||
)}
|
||||
sections={[
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title1'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item1'</span>, <span class="hljs-string">'item2'</span>]},
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title2'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item3'</span>, <span class="hljs-string">'item4'</span>]},
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title3'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item5'</span>, <span class="hljs-string">'item6'</span>]},
|
||||
]}
|
||||
keyExtractor={(item, index) => item + index}
|
||||
/>
|
||||
</code></pre>
|
||||
<pre><code class="hljs css javascript">// Example 2 (Heterogeneous Rendering / No Section Headers)
|
||||
const overrideRenderItem = ({ item, index, section: { title, data } }) => <Text key={index}>Override{item}</Text>
|
||||
|
||||
@@ -19,15 +19,7 @@
|
||||
</code></pre>
|
||||
<p>This command prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called <code>my-release-key.keystore</code>.</p>
|
||||
<p>The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.</p>
|
||||
<p>On Mac if you not sure where is your jdk bin folder is then perform the following command to find it,
|
||||
<code>$ /usr/libexec/java_home</code>
|
||||
it will output the directroy of jdk which looks like this,
|
||||
<code>/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home</code>
|
||||
then navigate to that directory by the following command,
|
||||
<code>$ cd /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/</code>
|
||||
Now you can perform the keytool command with sudo permission as shown below,
|
||||
<code>$ sudo keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000</code></p>
|
||||
<p><em>Note: Remember to keep your keystore file private and never commit it to version control.</em></p>
|
||||
<p>On Mac if you not sure where is your jdk bin folder is then perform the following command to find it, <code>$ /usr/libexec/java_home</code> it will output the directroy of jdk which looks like this, <code>/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home</code> then navigate to that directory by the following command, <code>$ cd /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/</code> Now you can perform the keytool command with sudo permission as shown below, <code>$ sudo keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000</code> <em>Note: Remember to keep your keystore file private and never commit it to version control.</em></p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="setting-up-gradle-variables"></a><a href="#setting-up-gradle-variables" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Setting up gradle variables</h3>
|
||||
<ol>
|
||||
<li>Place the <code>my-release-key.keystore</code> file under the <code>android/app</code> directory in your project folder.</li>
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<span class="xml"><span class="hljs-tag"><<span class="hljs-name">View</span>></span>
|
||||
<span class="hljs-tag"><<span class="hljs-name">Text</span>></span>Hello world!<span class="hljs-tag"></<span class="hljs-name">Text</span>></span>
|
||||
<span class="hljs-tag"></<span class="hljs-name">View</span>></span></span>
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
</code></pre><iframe style="margin-top: 4" width="880" height="420" data-src="//cdn.rawgit.com/dabbott/react-native-web-player/gh-v1.10.0/index.html#code=import%20React%2C%20%7B%20Component%20%7D%20from%20'react'%3B%0Aimport%20%7B%20Text%20%7D%20from%20'react-native'%3B%0A%0Aexport%20default%20class%20HelloWorldApp%20extends%20Component%20%7B%0A%20%20render()%20%7B%0A%20%20%20%20return%20(%0A%20%20%20%20%3CView%3E%0A%20%20%20%20%20%20%3CText%3EHello%20world!%3C%2FText%3E%0A%20%20%20%20%3C%2FView%3E%0A%20%20%20%20%20%20%0A%20%20%20%20)%3B%0A%20%20%7D%0A%7D%0A" frame-border="0"></iframe></div>
|
||||
</code></pre><iframe style="margin-top: 4" width="880" height="420" data-src="//cdn.rawgit.com/dabbott/react-native-web-player/gh-v1.10.0/index.html#code=import%20React%2C%20%7B%20Component%20%7D%20from%20'react'%3B%0Aimport%20%7B%20Text%20%7D%20from%20'react-native'%3B%0A%0Aexport%20default%20class%20HelloWorldApp%20extends%20Component%20%7B%0A%20%20render()%20%7B%0A%20%20%20%20return%20(%0A%20%20%20%20%3CView%3E%0A%20%20%20%20%20%20%3CText%3EHello%20world!%3C%2FText%3E%0A%20%20%20%20%3C%2FView%3E%0A%0A%20%20%20%20)%3B%0A%20%20%7D%0A%7D%0A" frame-border="0"></iframe></div>
|
||||
|
||||
<p>If you are feeling curious, you can play around with sample code directly in the web simulators. You can also paste it into your <code>App.js</code> file to create a real app on your local machine.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="what-s-going-on-here"></a><a href="#what-s-going-on-here" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What's going on here?</h2>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -213,9 +213,7 @@
|
||||
</table>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="originwhitelist"></a><a href="#originwhitelist" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>originWhitelist</code></h3>
|
||||
<p>List of origin strings to allow being navigated to. The strings allow wildcards and get matched against <em>just</em> the origin (not the full URL).
|
||||
If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS.
|
||||
The default whitelisted origins are "http://<em>" and "https://</em>".</p>
|
||||
<p>List of origin strings to allow being navigated to. The strings allow wildcards and get matched against <em>just</em> the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://<em>" and "https://</em>".</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Type</th><th>Required</th></tr>
|
||||
@@ -445,8 +443,7 @@ The default whitelisted origins are "http://<em>" and "https://</
|
||||
</table>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="geolocationenabled"></a><a href="#geolocationenabled" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><code>geolocationEnabled</code></h3>
|
||||
<p>Set whether Geolocation is enabled in the <code>WebView</code>. The default value is <code>false</code>.
|
||||
Used only in Android.</p>
|
||||
<p>Set whether Geolocation is enabled in the <code>WebView</code>. The default value is <code>false</code>. Used only in Android.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Type</th><th>Required</th><th>Platform</th></tr>
|
||||
|
||||
+13
-10
@@ -27,16 +27,19 @@
|
||||
</ul>
|
||||
<p>If you don't need section support and want a simpler interface, use <a href="/react-native/docs/flatlist.html"><code><FlatList></code></a>.</p>
|
||||
<p>Simple Examples:</p>
|
||||
<pre><code class="hljs css javascript"><span class="hljs-comment">// Example 1 (Homogeneous Rendering) </span>
|
||||
<SectionList
|
||||
renderItem={({ item, index, section }) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{index}</span>></span>{item}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
renderSectionHeader={({ <span class="hljs-attr">section</span>: { title } }) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">fontWeight:</span> '<span class="hljs-attr">bold</span>' }}></span>{title}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
sections={[
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title1'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item1'</span>, <span class="hljs-string">'item2'</span>] },
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title2'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item3'</span>, <span class="hljs-string">'item4'</span>] },
|
||||
{ <span class="hljs-attr">title</span>: <span class="hljs-string">'Title3'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item5'</span>, <span class="hljs-string">'item6'</span>] },
|
||||
]}
|
||||
keyExtractor={(item, index) => item + index} />
|
||||
<pre><code class="hljs css javascript"><span class="hljs-comment">// Example 1 (Homogeneous Rendering)</span>
|
||||
<SectionList
|
||||
renderItem={({item, index, section}) => <span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{index}</span>></span>{item}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>}
|
||||
renderSectionHeader={({<span class="hljs-attr">section</span>: {title}}) => (
|
||||
<span class="xml"><span class="hljs-tag"><<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{fontWeight:</span> '<span class="hljs-attr">bold</span>'}}></span>{title}<span class="hljs-tag"></<span class="hljs-name">Text</span>></span></span>
|
||||
)}
|
||||
sections={[
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title1'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item1'</span>, <span class="hljs-string">'item2'</span>]},
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title2'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item3'</span>, <span class="hljs-string">'item4'</span>]},
|
||||
{<span class="hljs-attr">title</span>: <span class="hljs-string">'Title3'</span>, <span class="hljs-attr">data</span>: [<span class="hljs-string">'item5'</span>, <span class="hljs-string">'item6'</span>]},
|
||||
]}
|
||||
keyExtractor={(item, index) => item + index}
|
||||
/>
|
||||
</code></pre>
|
||||
<pre><code class="hljs css javascript">// Example 2 (Heterogeneous Rendering / No Section Headers)
|
||||
const overrideRenderItem = ({ item, index, section: { title, data } }) => <Text key={index}>Override{item}</Text>
|
||||
|
||||
Reference in New Issue
Block a user