我有一个React Native应用程序,可以在Chrome调试器打开时正常工作.一旦我禁用它,每当我尝试进行任何Parse调用时,我都会收到以下错误:
- Parse.User.logIn(
- email,password,{
- success: function(res) {
- console.log('success');
- },error: function(error) {
- console.log(error.code + ' ' + error.message);
- }
- }
- );
我已经尝试删除控制台语句,以防错误与控制台不可用,但无济于事.这种情况发生在其他Parse调用中,并且总是与缺少的localStorage变量有关.
在此先感谢您的帮助!
更新:
看起来Firebase存在类似问题. https://groups.google.com/forum/#!topic/firebase-talk/Y_usPRhOIYA
他们提到问题与没有localStorage的polyfill有关.
解决方法
上面的答案在技术上是正确的,但Parse提供了一个不需要polyfil或降级的解决方案.这是由于我永远缺乏阅读.我在
Parse React docs上发现了这个:
As of version 1.6,the Parse JS SDK has a different build for React
Native. If you’re using Parse+React on React Native,you’ll need to
require the ‘parse-react/react-native’ package instead.
例如:
- // 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添加数据订阅.