【问题标题】:Invariant Violation: View config not found for name div. Make sure to start component names with a capital letter. in react native不变违规:未找到名称 div 的视图配置。确保以大写字母开头组件名称。在本机反应
【发布时间】:2020-03-06 06:23:38
【问题描述】:

我是反应原生的初学者,我尝试构建非常基本的应用程序,但出现以下错误

Invariant Violation: View config not found for name div. Make sure to start component names with a capital letter.

此错误位于: 在 div 中(由 View 创建) 在视图中(由 ScrollView 创建) 在 div 中(由 View 创建) 在视图中(由 ScrollViewBase 创建) 在 ScrollViewBase(由 ScrollView 创建) 在 ScrollView 中(在 Horizo​​ntal.js:8 处) 在水平(在 App.js:12) 在 RCTView 中(在 View.js:45) 在视图中(在 App.js:11) 在应用程序中(在 withExpoRoot.js:20) 在 RootErrorBoundary 中(在 withExpoRoot.js:19) 在 ExpoRootComponent 中(在 renderApplication.js:35) 在 RCTView 中(在 View.js:45) 在视图中(在 AppContainer.js:98) 在 RCTView 中(在 View.js:45) 在视图中(在 AppContainer.js:115) 在 AppContainer 中(在 renderApplication.js:34 处) 得到

下面是我的源码

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {ScrollView} from "react-native-web";

export default class Horizontal extends React.Component{
render() {
    return (
        <ScrollView>
            <View>
                <Text style={styles.innerText}>
                    Welcome to LCOs
                </Text>
            </View>
        </ScrollView>
    );
}
}

const styles = StyleSheet.create({
container: {
},
outer: {

},
innerText:{},
});

这是我的主要课程

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Red from './component/Red';
import Green from "./component/Green";
import Blue from "./component/Blue";
import Horizontal from "./component/Horizontal";

export default class App extends React.Component{
  render() {
    return (
        <View style={styles.container}>
          <Horizontal/>
        </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent:'center',
flexDirection:'row'
  },
});

此错误的原因是什么,我该如何解决?

【问题讨论】:

  • 为什么要从 react-native-web 实现 ScrollView?你能把它从“react-native”改过来吗?

标签: react-native


【解决方案1】:

好的,我找到了解决方案,将滚动视图的输入更改为响应原生而不是响应原生 web

从“react-native-web”更改导入 {ScrollView};这到 从“react-native”导入 {ScrollView};这个。

【讨论】:

  • 我说的是真的:)
猜你喜欢
  • 1970-01-01
  • 2018-08-04
  • 1970-01-01
  • 2020-08-14
  • 1970-01-01
  • 2015-08-03
  • 2018-06-29
相关资源
最近更新 更多