Native中找不到localStorage变量

Native中找不到localStorage变量

本文介绍了Parse在React Native中找不到localStorage变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个React Native应用程序,可以在Chrome调试器打开时正常运行。一旦我禁用它,每当我尝试进行任何Parse调用时,我都会收到以下错误:

I have a React Native app that works fine with the Chrome debugger open. Once I disable it though, I keep getting the following error whenever I try to make any Parse calls:

调用堆栈返回以下代码,尝试登录用户:

The call stack leads back to the following code attempting to log a user in:

Parse.User.logIn(
  email,
  password,
  {
    success: function(res) {
      console.log('success');
    },
    error: function(error) {
      console.log(error.code + ' ' + error.message);
    }
  }
);

我已经尝试删除控制台语句,以防错误与控制台不一致可用,但无济于事。其他Parse调用会发生这种情况,并且总是与丢失的 localStorage 变量有关。

I've tried removing the console statements, in case the error had to do with the console not being available, but no avail. This happens with other Parse calls, and always has to do with the missing localStorage variable.

提前感谢任何帮助!

更新:

看起来Firebase存在类似问题。

Looks like there is a similar issue with Firebase. https://groups.google.com/forum/#!topic/firebase-talk/Y_usPRhOIYA

他们提到问题与没有localStorage的polyfill有关。

They mention that the problem has to do with there not being a polyfill for localStorage.

推荐答案

上面的答案在技术上是正确的,但Parse提供了一个不需要polyfil或降级的解决方案。这是由于我永远缺乏阅读。我在上找到了这个:

The answers above are technically right, but Parse has provided a solution that doesn't require a polyfil or downgrading. This was due to my perpetual lack of reading. I found this on the Parse React docs:

例如:

// For React Native apps
var React = require('react-native');
var Parse = require('parse/react-native');
var ParseReact = require('parse-react/react-native');

很抱歉没有提到我也在使用Parse React。我认为问题仅在于Parse,因为我还没有开始通过Parse React添加数据订阅。

Sorry for not mentioning I was using Parse React as well. I thought the problem was just with Parse, as I hadn't begun to add data subscriptions via Parse React.

这篇关于Parse在React Native中找不到localStorage变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:34