我使用 Meteor 和 React Native 来显示用户选择的代理。如果用户更改了他的代理,字段{number}
刷新,但{depute.nom}
并{depute.groupe_sigle}
没有。我应该使用 Tracker Autorun 吗?任何想法 ?
class Info extends Component {
render() {
const {nom, groupe_sigle, nom_circo, picture, num_circo, id} = this.props.navigation.state.params;
//This updates into the component
const number= Meteor.user().profile.selectedDeputy;
//This does not update into the component
const depute= this.props.selectedDeputy && this.props.selectedDeputy.depute;
return (
<View>
<Text>Your deputy is : {depute.nom}</Text>
<Text>Your deputy group is : {depute.groupe_sigle} </Text>
<Text>The deputy Id gets updated : {number} </Text>
</View>
)
}
}
export default createContainer(params=>{
Meteor.subscribe('selectedDeputy');
return{
selectedDeputy: Meteor.collection('deputies').findOne(Meteor.user().profile.selectedDeputy),
};
},info);