Firebase “value”事件不会在 React Native 中触发
Firebase 'value' events aren't firing in React Native
我有一个函数,意思是订阅Firebase子网址上的value
事件。它看起来像
function getMessages(chat) {
var ref = new Firebase(".../"+chat+"/messages");
ref.limitToLast(10).on('value', function(snapshot) {
...
});
}
这是从 React 组件的 componentWillMount
方法调用的,如下所示:
componentWillMount() {
getMessages(this.props.chat);
}
我第一次调用这个函数时,一切正常,而且速度非常快。但是,如果我使用不同的chat
参数调用它,则回调永远不会触发。第一次加载甚至没有一次。
据我所知,通过将console.log
放在每隔一行上,componentWillMount
正在发射,getMessages
正在被调用。
什么给?有什么想法吗?
谢谢。
编辑:请注意,我正在尝试在 React Native 中实现这一点。我进一步简化了,让我的 React 组件直接连接到 firebase。看看这个小提琴。这在小提琴中完美运行,但在 React Native 中,当它第一次连接时,如果您单击返回并进入另一个聊天,它将永远不会触发value
事件。
在一个全新的项目中,它似乎有效,所以问题一定出在其他地方。这是一个要点。
相关文章:
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- 使用Jest测试React Native应用程序
- 是否存在React Native“;WEB代码安全防护”;
- React Native Listview留有余地
- 如何在React Native中绘制图形
- 在iOS和Android上使用React native时,我还能使用本机第三方lirbraries吗
- 使用createContainer将Meteor数据获取到React Native中时出现问题
- React Native当前是否支持访问用户'的通讯簿
- React Native-What'It’在任何地方都要留下逗号
- React Native DeviceEventEmitter键盘WillShow停止工作
- 与React Native的Chart.js等效
- 如何使用webview在React Native中使用Highcharts
- 如何在React Native的MapView中设置标记
- React Native NavigatorIOS
- 如何获得React Native TextInput以在提交后保持焦点
- 使用react native检测应用程序终止
- 可以在React Native中制作一个自哈希应用程序
- React Native + React - Native -router-flux:
- React Native + React - Native -router-flux:如何仅将hideNavBar应用于
- React Native-React Packager发送旧代码