React Native + Firebase:是否可以在不同的ref中呈现多个数据值?

时间:2017-01-23 10:47:11

标签: firebase react-native firebase-realtime-database

数据结构示例:

  "post": {
    "postId": {
      "name": ".....",
      "data1": "....",
    },
  "users": {
    "userId": {
      "username": "....",
      "data2"
   }
  }

是否可以在同一个列表视图中呈现(data1 / data2)?

像这样:

_renderList(lists) {
  return(
     <View>
       <Text>{lists.data1}</Text>
       <Text>{lists.data2}</Text>
     </View>
  )
}

我尝试在构造函数中设置两个ref(),但它不起作用:

constructor(props){
  super(props);
  this.state = {
   dataSource: new ListView.DataSource({
      rowHasChanges: (row1, row2) => row1 !==row2,
    }),
  }
  this.listsRef = firebase.database().ref('post');
  this.listsUserRef = firebase.database().ref('users').child(uid)
}

0 个答案:

没有答案