【问题标题】:Provided an image that is available locally already提供已在本地可用的图像
【发布时间】:2017-11-05 10:27:42
【问题描述】:

我在我的应用中使用 React Native 和 Firebase。我突然开始收到这个错误:

SyntaxError: Unexpected end of JSON input.
at doWrite(_stream_writable.js)
at Promise.resolve.then.then.then.catch.then.message

在我的反应包装器中它指向这个代码:

    onProfilesChange = async (snap) => {
    var allProfilePromises = []
    snap.forEach((child) => {
      var profileId = child.val().profileId
      var alreadyAdded = this.state.profiles.some(x => x.id === profileId)

      if (alreadyAdded === false) {
        var profilePromise = this.registerOnProfileChanges(profileId)
        allProfilePromises.push(profilePromise)
      }
    })

    await Promise.all(allProfilePromises)

    var profileCount = snap.numChildren()
    this.setState({ profiles: this.state.profiles, loading: false, profileCount: profileCount })

    if (profileCount <= 0) {
      this.getUserName()
    }
  }

在调用 componentMount 时正在运行。现在错误很清楚,但我不知道为什么会产生它,也不知道如何通过它。这段代码已经运行了几个月,我没有对其进行任何更改。

提前致谢。

【问题讨论】:

    标签: android firebase react-native


    【解决方案1】:

    尝试清除缓存并重新启动服务器...

    cd android & gradlew clean & cd .. & rm -rf node_modules/ & npm cache clean --force & yarn install & react-native run-android
    

    您可能想要使用npm i 而不是yarn install

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。它与图像有关。
      我通过更改 react-native-img-cache 的版本解决了这个问题。
      运行这个:
      npm install react-native-img-cache@1.4.0

      【讨论】:

        猜你喜欢
        • 2013-08-10
        • 1970-01-01
        • 1970-01-01
        • 2011-06-18
        • 1970-01-01
        • 1970-01-01
        • 2021-12-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多