Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 不变冲突试图获取超出范围的帧索引NaN_Firebase_React Native - Fatal编程技术网

Firebase 不变冲突试图获取超出范围的帧索引NaN

Firebase 不变冲突试图获取超出范围的帧索引NaN,firebase,react-native,Firebase,React Native,我正在从运行react本机聊天应用程序示例,并遇到帧超出范围错误: 下面是package.json: "firebase": "^5.8.0", "react": "16.6.3", "react-native": "0.57.8", "react-native-elements": "^0.19.1", "react-native-gesture-handler": "^1.0.15", "react-native-gifted-chat": "^0.

我正在从运行react本机聊天应用程序示例,并遇到帧超出范围错误:

下面是package.json:

 "firebase": "^5.8.0",
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-elements": "^0.19.1",
    "react-native-gesture-handler": "^1.0.15",
    "react-native-gifted-chat": "^0.7.0",
    "react-navigation": "^3.0.9"
网上有一些关于不同情况下错误的帖子。错误指向Chat.js中的GiftedChat。我也不知道是什么导致了这个错误

import React, { Component} from 'react';
import {View, StyleSheet } from 'react-native';
import { GiftedChat } from 'react-native-gifted-chat';
import Fire from '../Fire';

class Chat extends React.Component {
    static navigationOptions = ({ navigation}) => ({
        title: (navigation.state.params || {}).name || 'Chat!',
    });

    state = {
        messages: {},
    };

    componentDidMount() {
        Fire.shared.on(message =>
              this.setState(previousState => ({
                messages: GiftedChat.append(previousState.messages, message),
              }))
        );
    }

    componentWillUnmount() {
      Fire.shared.off();
    }

    get user() {
      // return our name and our UID for GiftedChat to parse
      return {
          name: this.props.navigation.state.params.name,
          _id: Fire.shared.uid,
      };
    }

    render() {
        return (
            <GiftedChat   <<<<==this is line:37
              messages={this.state.messages}
              onSend={Fire.shared.send}
              user={this.user}
            /> 
        );
    }
}

const styles = StyleSheet.create({});



export default Chat;

消息的错误似乎处于初始状态

您已将您的州定义为

state = { 
  messages: {} 
}
消息应定义为数组,因此将初始状态更新为

state = { 
  messages: []
}
从文件中

消息数组-要显示的消息
消息的错误似乎处于初始状态

您已将您的州定义为

state = { 
  messages: {} 
}
消息应定义为数组,因此将初始状态更新为

state = { 
  messages: []
}
从文件中

消息数组-要显示的消息