查看配置 getter 组件 'div' 的回调必须是一个函数(已收到 'undefined')。确保组件名称以大写字母开头

view config getter callback for component 'div' must be a function (received 'undefined'). Make sure to start component names with a capital letter

错误是:不变违规:视图配置 getter 组件 'div' 的回调必须是一个函数(已收到 'undefined')。确保组件名称以大写字母开头。 我在尝试从 firebase 检索数据到 React Native 的 table 组件 ReactTable 时遇到此错误,并且在我的控制台中查看数据时还在控制台中给出一个空数组,因此输出中没有任何内容。

import React, { Component } from 'react';
import { StyleSheet, View, Text, Button } from 'react-native';
import ReactTable from 'react-table';
import firebase from 'firebase';


const firebaseConfig = {
...
};
firebase.initializeApp(firebaseConfig);


export default class Form1 extends Component {
constructor(props) {
    super(props);

    this.state = {
        data: [],
        columns: [
            {
                Header: "email",
                accessor: "email"
            },
            {
                Header: "password",
                accessor: "password"
            }
        ]
    }
}

componentDidMount() {
    const data = [];
    var query = firebase.database().ref("users");
    query.once("value").then((snapshot) => {
        snapshot.forEach((childSnapshot, index) => {
            let singleObj = {
                email: childSnapshot.val().email,
                password: childSnapshot.val().password,
            }
            data.push(singleObj);

            if (index === snapshot.length - 1) {
                this.setState({ data: data });
            }
        });
    });
}

render() {
    return (
        <div>
            {this.state.data.length > 0 && <ReactTable data={this.state.data} columns= 
{this.state.columns} />}
        </div>
    );
}
}

const styles = StyleSheet.create({
container: { flex: 1, padding: 16, paddingTop: 30, backgroundColor: '#fff' },
head: { height: 40, backgroundColor: '#f1f8ff' },
text: { margin: 6 }
});

你不能在 React Native 中使用 div 用 View 改变它

改变

      <div>
            {this.state.data.length > 0 && <ReactTable data={this.state.data} columns= 
{this.state.columns} />}
        </div>

        <View>
            {this.state.data.length > 0 && <ReactTable data={this.state.data} columns= 
{this.state.columns} />}
        </View>

希望对您有所帮助!

有时您定义的视图必须是大写字母。

const PresentationalComponent = (props) => {
   return (
    **<View>**
     <HeaderText></HeaderText>
    **</View>**
    
    
        
      
   )
}
export default PresentationalComponent

有时当您的组件导入不正确时会出现此错误。在我的 react-native 项目中,FlatList 是从 react-native-web 而不是 react-native 框架导入的,这导致了上述错误。当我从 react-native 框架导入它时,它工作正常。

我收到了一个类似的错误,上面写着

错误是:不变违规:视图配置 getter 组件 'form' 的回调必须是一个函数(已收到 'undefined')。

我的问题是我使用的是来自 formik 的网络版本,所以我只需要使用将 Form 更改为 View 的 React Native。

希望对其他人有所帮助。

当您从 eq 的错误组件模块导入组件时发生错误。如果你导入 来自 react-native-web 而不是 react-native

的“TouchableOpacity”