Trên iOS và Android, string không phải là một loại view. UIView không biết cách render ký tự — chỉ UILabel/TextView mới làm được. RN buộc bạn bao text trong <Text> để binding sang đúng native component.
Nếu viết <View>Hello</View>, RN throw runtime error: "Text strings must be rendered within a <Text> component." Trên web, <div>Hello</div> chạy được vì DOM cho phép text node bất cứ đâu.
Khác biệt phụ kéo theo:
- Style font, color, lineHeight chỉ áp dụng được trên <Text> — set trên <View> không có tác dụng.
- <Text> lồng trong <Text> thì kế thừa style cha (giống <span> trong <p>); nhưng <Text> lồng trong <View> thì không kế thừa.
- numberOfLines, ellipsizeMode chỉ tồn tại trên <Text>.
On iOS and Android, a string is not a view. UIView cannot render characters — only UILabel/TextView can. RN forces you to wrap text in <Text> so it binds to the correct native component.
<View>Hello</View> throws "Text strings must be rendered within a <Text> component." On the web, <div>Hello</div> works because the DOM allows text nodes anywhere.
Knock-on differences:
- Font/color/lineHeight only apply on <Text> — they do nothing on <View>.
- A <Text> nested in another <Text> inherits style from the parent (like <span> in <p>); a <Text> inside <View> does not inherit.
- numberOfLines and ellipsizeMode exist only on <Text>.