【问题标题】:CRNA, genymotion, expo weird errorCRNA、genymotion、expo 奇怪的错误
【发布时间】:2018-08-28 02:44:10
【问题描述】:

我正在使用 genymotion 来运行我的 React Native 开发环境。加载特定组件时,我会收到 console.error 消息:there was a problem sending log messages to your development environment 带有奇怪的堆栈跟踪,它使用 <unknown> 代替几个命名函数。

我将问题缩小到代码中的一个组件:

class Questions extends React.Component {
  constructor(props){
    super(props);
    this.state = {
                  style: 'all',
                  selected: ''}
  }
  render = () => {
    return (
      <View style={styles.questions}>
        <ScrollView>
          {(this.props.questions && this.state.style == 'all')&&
            this.props.questions.map(post => {
              return (
                <TouchableHighlight onPress={() => this.loadQuestion(post)} key={post.ID + new Date(post.post_date)} style={styles.questionCard} >
                  <View style={styles.questionCard} >
                    <View style={styles.title}>
                      <Text style={{color: 'white'}}>{post.post_title}</Text>
                      <Text style={{color: 'white'}}> - {post.display_name} {utils.timeSince(new Date(post.post_date))}</Text>
                    </View>
                  </View>
                </TouchableHighlight>
              )
            })
          }
        </ScrollView>
      </View>
    )
  }
}

每当加载此组件时,我都会收到上面提到的 console.error。我知道这没什么好继续的,我什至不期待答案,但我不知所措。

如果你用谷歌搜索那个确切的错误信息,你会在 Github 上发现一个没有解决的问题,提到它可能是 expo sdk 中的一个错误(这是有道理的)并链接了另一个 404s 问题。

【问题讨论】:

    标签: react-native genymotion expo


    【解决方案1】:

    好的,我想我解决了,问题实际上出在我的 utils 函数 timeSince 中。我有一个杂散的 console.log() 语句,当我删除它时,错误就消失了。显然,使用此配置,您无法从内部资产调用 console.log()。

    编辑:好的,经过进一步调试后,当您尝试 console.log() 一个对象时会引发此错误,日志的来源无关紧要。

    【讨论】:

      【解决方案2】:

      好的,我想我解决了,问题实际上出在我的 utils 函数 timeSince 中。我有一个杂散的 console.log() 语句,当我删除它时,错误就消失了。显然,使用此配置,您无法从内部资产调用 console.log()。

      编辑:好的,经过进一步调试后,当您尝试 console.log() 一个对象时会引发此错误,而日志的来源无关紧要。

      我希望这能进一步阐明这个“错误”的根源:

      您所指的对象实际上是调用的响应,它不喜欢它的大小。它不是任何对象,只是来自调用的 response 对象。如果你尝试解构你想要的部分,那么它就会消失

      【讨论】:

      • 请在这里提供完整的答案,不要让寻找问题解决方案的人去点击其他页面的链接来解决问题。如果这个问题确实是另一个问题的重复,那么不要回答,等待足够的声誉来标记为重复。
      猜你喜欢
      • 2019-01-17
      • 2010-11-17
      • 1970-01-01
      • 2014-10-11
      • 2012-04-27
      • 2013-10-30
      • 2016-09-18
      • 2012-03-18
      • 2015-05-13
      相关资源
      最近更新 更多