mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Updated docs for next
This commit is contained in:
@@ -56,7 +56,7 @@ html <span class="token punctuation">{</span>
|
||||
font<span class="token operator">-</span>family<span class="token punctuation">:</span> <span class="token string">'lucida grande'</span><span class="token punctuation">,</span> tahoma<span class="token punctuation">,</span> verdana<span class="token punctuation">,</span> arial<span class="token punctuation">,</span> sans<span class="token operator">-</span>serif<span class="token punctuation">;</span>
|
||||
font<span class="token operator">-</span>size<span class="token punctuation">:</span> 11px<span class="token punctuation">;</span>
|
||||
color<span class="token punctuation">:</span> #<span class="token number">141823</span><span class="token punctuation">;</span>
|
||||
<span class="token punctuation">}</span></div><p>When the browser is trying to render a text node, it's going to go all the way up to the root element of the tree and find an element with a <code>font-size</code> attribute. An unexpected property of this system is that <strong>any</strong> node can have <code>font-size</code> attribute, including a <code><div></code>. This was designed for convenience, even though not really semantically correct.</p><p>In React Native, we are more strict about it: <strong>you must wrap all the text nodes inside of a <code><Text></code> component</strong>; you cannot have a text node directly under a <code><View></code>.</p><div class="prism language-javascript"><span class="token comment" spellcheck="true">// BAD: will fatal, can't have a text node as child of a <View>
|
||||
<span class="token punctuation">}</span></div><p>When the browser is trying to render a text node, it's going to go all the way up to the root element of the tree and find an element with a <code>font-size</code> attribute. An unexpected property of this system is that <strong>any</strong> node can have <code>font-size</code> attribute, including a <code><div></code>. This was designed for convenience, even though not really semantically correct.</p><p>In React Native, we are more strict about it: <strong>you must wrap all the text nodes inside of a <code><Text></code> component</strong>; you cannot have a text node directly under a <code><View></code>.</p><div class="prism language-javascript"><span class="token comment" spellcheck="true">// BAD: will raise exception, can't have a text node as child of a <View>
|
||||
</span><View<span class="token operator">></span>
|
||||
Some text
|
||||
<<span class="token operator">/</span>View<span class="token operator">></span>
|
||||
|
||||
Reference in New Issue
Block a user