【发布时间】:2015-12-12 08:22:15
【问题描述】:
我正在尝试将“reactfire”mixin 与 react native 一起用于我的应用程序。
我安装了 npm 模块。
$ npm install reactfire --save
我将该模块包含在我的“index.ios.js”文件中
var ReactFireMixin = require('./node_modules/reactfire');
我在类中添加了 mixin
mixins: [ReactFireMixin],
我说
getInitialState: function() {
return {
items: [],
}
},
componentWillMount: function() {
var ref = new Firebase('https://<MY APP NAME>.firebaseio.com/tasks');
this.bindAsArray(ref, 'items');
console.log(ref);
console.log(this.state.items);
}
我得到了
我可以很好地使用“firebase”npm 模块,但不能使用“reactfire”模块,我想在我的应用程序中使用 mixin 而不是其他替代方案。
我也很好奇这个特殊的 mixin 如何处理离线使用。
PS:firebase documentation 存在缺陷,因为只执行 'mixins: [ReactFireMixin],' 并没有做任何事情,并且在为 react native 开发时,您没有 html 文件。
是的,我是一个 react 新手,所以这可能只是在浪费你的时间。
这是完整代码 - github repo
【问题讨论】:
-
问题到底是什么?还是错误?
-
因此,“this.state.items”中应该显示对象,并且由于 bindAsArray() 调用,console.log 语句应该打印出对象,但数组是空的,并且Firebase 参考看起来像加密
-
而我的表格视图是空的,不显示任何数据行
-
firebase ref 在网络上看起来有什么不同吗?看起来它可能只是缩小了。如果 reactfire 不适用于 react native,我不会感到惊讶
-
可能是它不起作用,但我认为它是,或者看到他们在某处说过,不知道你的意思是“firebase 在网络上看起来不一样吗?”
标签: javascript firebase react-native mixins