错误是:不变冲突:组件"div"的视图配置getter回调必须是函数(接收到"未定义").确保组件名称以大写字母开头.

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,请在视图中更改它

改变

      <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>

希望这有帮助!

React-native相关问答推荐

'无法解析模块.安装react-native-pager-view后的实用程序/平台

expo 使用错误的版本代码创建建筑

react 本机 TextInput 将其他元素移出屏幕

使用下拉菜单时react 本机react-native-dropdown-select-list,它会将下面的项目向下移动.如何阻止这种情况发生

如何在堆栈的任何屏幕的后退按钮按下时始终导航到堆栈的初始路径?

react平面列表渲染项

React-native 重置数据库

React Native 将 base64 图像保存到相册

如何在react-native android中打开应用程序设置页面?

React-native 组件的 elevation样式导致的阴影

如何将组件中的props传递给 FlatList renderItem

在 Windows 上进行本机调试

React Native require(image) 返回数字

如何在 React Native 中使用 Jest

React Native 从导航堆栈中清除上一个屏幕

在 React-Native 中手动设置 opacity 的 onPress of TouchableOpacity 的音量

居中图像 React Native 加载屏幕

为什么我收到警告:函数作为 React 子级无效?

React Native font outline / textShadow

React Native 项目,有时使用 expo start 获得连接 ECONNREFUSED 127.0.0.1:19001