javascript 不变违规:未找到名称 div 的查看配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48179638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invariant Violation: View config not found for name div
提问by monk
I want to render in react-native project. But simulator shows me the error:
Invariant Violation: View confignot found for name div
What is the matter?
Is there a solution for rendering <div>in react-native?
我想在 react-native 项目中渲染。但是模拟器向我显示了错误:不变违规:View config未找到名称 div 怎么了?是否有<div>在 react-native 中渲染的解决方案?
Code sample:
代码示例:
render() {
return (
<div>123</div>
);
}
回答by Ahsan Ali
<div>is an invalid React Native Component
<div>是无效的 React Native Component
You should use React Native Basic Components
你应该使用React Native 基本组件
import { View, Text } from 'react-native';
render() {
return (
<View>
<Text>123</Text>
</View>
);
}
Viewis a container that supports layout with flexbox, style, some touch handling, and access controls. Whereas <Text>can be used in order to display any text.
View是一个容器,它支持带有 flexbox、样式、一些触摸处理和访问控制的布局。而<Text>可用于显示任何文本。
回答by Dan O
the React Native documentationdoes not list HTML elements as valid view components. There is no view config for <div>because <div>is not a React Native component.
该阵营本地文件没有做列表的HTML元素为有效视图组件。<div>因为<div>不是 React Native 组件,所以没有视图配置。

