不变违规试图使帧超出范围索引NaN

时间:2019-01-25 21:52:18

标签: firebase react-native

我正在从Even Bacon运行一个ansicolor聊天应用示例,并遇到import 'package:ansicolor/ansicolor.dart'; main(List<String> arguments) { AnsiPen greenPen = AnsiPen()..green(); AnsiPen greenBackGroundPen = AnsiPen()..green(bg: true); AnsiPen redTextBlueBackgroundPen = AnsiPen()..blue(bg: true)..red(); AnsiPen boldPen = AnsiPen()..white(bold: true); AnsiPen someColorPen = AnsiPen()..rgb(r: .5, g: .2, b: .4); print(greenPen("Hulk") + " " + greenBackGroundPen("SMASH!!!")); print(redTextBlueBackgroundPen("Spider-Man!!!") + " " + boldPen("Far From Home!!!")); print(someColorPen("Chameleon")); } 错误:

enter image description here

这是package.json:

react-native

关于不同情况下的错误,有一些在线帖子。错误指向Chat.js中的frame out of range NaN。而且我不知道是什么原因导致了错误。

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

1 个答案:

答案 0 :(得分:1)

错误似乎是在您的消息初始状态。

您已将状态定义为

state = { 
  messages: {} 
}

消息应定义为数组,因此将初始状态更新为

state = { 
  messages: []
}

从文档中

  
      
  • 消息(数组)-显示的消息
  •   

https://github.com/FaridSafi/react-native-gifted-chat#props