mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Deploy website
Deploy website version based on 77ad7d4e861b2cacc959494c3ba7d2c98f9c0f2c
This commit is contained in:
@@ -502,7 +502,7 @@ export default function Cafe() {
|
||||
<span class="token operator">/</span><span class="token operator">></span>
|
||||
</code></pre>
|
||||
<blockquote>
|
||||
<p>You might’ve noticed that although <code>isHungry</code> is a <a href="https://developer.mozilla.org/Web/JavaScript/Reference/Statements/const">const</a>, it is seemingly reassignable! What is happening is when a state-setting function like <code>setIsHungry</code> is called, its component will re-render. In this case <code>Cat</code> will re-render its <code><Cat></code>—discarding the old <code>isHungry</code> and running <code>setState</code> again with the new value in the process!</p>
|
||||
<p>You might’ve noticed that although <code>isHungry</code> is a <a href="https://developer.mozilla.org/Web/JavaScript/Reference/Statements/const">const</a>, it is seemingly reassignable! What is happening is when a state-setting function like <code>setIsHungry</code> is called, its component will re-render. In this case the <code>Cat</code> function will run again—and this time, <code>useState</code> will give us the next value of <code>isHungry</code>.</p>
|
||||
</blockquote>
|
||||
<p>Finally, put your cats inside a <code>Cafe</code> component:</p>
|
||||
<pre><code class="hljs css language-jsx"><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">function</span> <span class="token function">Cafe</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
|
||||
@@ -502,7 +502,7 @@ export default function Cafe() {
|
||||
<span class="token operator">/</span><span class="token operator">></span>
|
||||
</code></pre>
|
||||
<blockquote>
|
||||
<p>You might’ve noticed that although <code>isHungry</code> is a <a href="https://developer.mozilla.org/Web/JavaScript/Reference/Statements/const">const</a>, it is seemingly reassignable! What is happening is when a state-setting function like <code>setIsHungry</code> is called, its component will re-render. In this case <code>Cat</code> will re-render its <code><Cat></code>—discarding the old <code>isHungry</code> and running <code>setState</code> again with the new value in the process!</p>
|
||||
<p>You might’ve noticed that although <code>isHungry</code> is a <a href="https://developer.mozilla.org/Web/JavaScript/Reference/Statements/const">const</a>, it is seemingly reassignable! What is happening is when a state-setting function like <code>setIsHungry</code> is called, its component will re-render. In this case the <code>Cat</code> function will run again—and this time, <code>useState</code> will give us the next value of <code>isHungry</code>.</p>
|
||||
</blockquote>
|
||||
<p>Finally, put your cats inside a <code>Cafe</code> component:</p>
|
||||
<pre><code class="hljs css language-jsx"><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">function</span> <span class="token function">Cafe</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
||||
|
||||
Reference in New Issue
Block a user