0

我使用 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);
4

1 回答 1

0

首先检查插入的数据是否存在于数据库中。如果数据未添加到数据库中,则您的插入函数存在问题。如果数据库中存在值,则您的订阅应该在自动运行中,否则您的数据将无法响应.如果您有冲突,请随时与我们分享您的代码

于 2018-01-29T10:32:38.950 回答