React-Native-Meteor软件包订阅句柄尚未准备好 [英] React-native-meteor package subscription handle not ready
问题描述
我正在尝试使用react-native-meteor软件包来组合react-native和meteor.流星成功发布了一个"dos"集合,我已经能够在Web客户端上订阅它.但是,在遵循了react-native-meteor软件包的文档(使用createContainer)之后,我无法订阅.手柄从未准备好".当使用来自Meteor的自动发布包时,数据会加载.
I'm trying to combine react-native and meteor using the react-native-meteor package. Meteor successfully publishes a 'dos' collection, which I have been able to subscribe to on the web client. However, after following the documentation of the react-native-meteor package (using createContainer) I am unable to subscribe; the handle is 'never ready'. When using the autopublish package from Meteor the data does load.
版本
Meteor 1.3.4.1
react-native: 0.28.0
react-native-meteor: 1.0.0-rc14
index.ios.js
index.ios.js
// @flow
'use strict'
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
View,
NavigatorIOS,
StatusBar,
Text,
} from 'react-native'
import Meteor, {
createContainer,
MeteorListView,
} from 'react-native-meteor'
Meteor.connect('ws://localhost:3000/websocket')
import GeoLocation from './app/GeoLocation'
import ConnectionInfoSubscription from './app/NetInfo'
import GridLayout from './app/GridLayout'
class DoCHANGE_0 extends Component {
renderRow(Do){
return(
<Text>{Do.joke}</Text>
)
}
render() {
const { doList, } = this.props
return (
<View style={styles.container}>
<StatusBar
barStyle="light-content"
/>
<NavigatorIOS
style = {styles.container}
barTintColor='#556270'
titleTextColor='#fff'
tintColor='#fff'
initialRoute={{
title: 'DoCHANGE',
component: GridLayout
}}/>
{!doList && <Text>Not ready with subscription</Text>}
<MeteorListView
collection="dos"
renderRow={this.renderRow}
enableEmptySections={true}
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex:1,
}
});
export default createContainer(params=>{
const handle = Meteor.subscribe('dos')
return {
doList: handle.ready(),
};
}, DoCHANGE_0)
AppRegistry.registerComponent('DoCHANGE_0', () => DoCHANGE_0);
我发现了类似的示例,但是它们通常不使用react-native-meteor包,而是使用ddpclient包.我是否在这里遗漏了一些明显的东西?任何见解都将不胜感激!
I have found similar examples but they often don't utilise the react-native-meteor package but use the ddpclient package instead. Am I missing something obvious here? Any insights is much appreciated!
(流星)/server/publish.js
(Meteor) /server/publish.js
Meteor.publish("dos", function() {
//console.log(Dos.find().fetch())
return Dos.find();
})
(流星)/both/collections.js
(Meteor) /both/collections.js
Dos = new Mongo.Collection('dos');
使用来自Meteor的自动发布时的屏幕截图. doList句柄仍未准备好.但是MeteorList正确填充了.
Screenshot when using autopublish from Meteor. doList handle is still not ready. But the MeteorList gets populated correctly.
推荐答案
我升级到了react-native,meteor和react-native-meteor的较新版本,但是并没有解决问题.但是,将renderRow函数重命名为renderItem时,它开始工作.
I upgraded to newer versions of react-native, meteor, and react-native-meteor but that didn't solve the issue. However, when renaming the renderRow function to renderItem it started working.
renderRow={this.renderRow}
renderRow={this.renderItem}
这篇关于React-Native-Meteor软件包订阅句柄尚未准备好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!