{"action":"created","issue":{"url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/13","repository_url":"https://api.github.com/repos/inProgress-team/react-native-meteor","labels_url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/13/comments","events_url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/13/events","html_url":"https://github.com/inProgress-team/react-native-meteor/issues/13","id":138061566,"number":13,"title":"Using ListView DataSource Best Practices with react-native-meteor 1.0.0-beta2","user":{"login":"radiegtya","id":2161622,"avatar_url":"https://avatars.githubusercontent.com/u/2161622?v=3","gravatar_id":"","url":"https://api.github.com/users/radiegtya","html_url":"https://github.com/radiegtya","followers_url":"https://api.github.com/users/radiegtya/followers","following_url":"https://api.github.com/users/radiegtya/following{/other_user}","gists_url":"https://api.github.com/users/radiegtya/gists{/gist_id}","starred_url":"https://api.github.com/users/radiegtya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radiegtya/subscriptions","organizations_url":"https://api.github.com/users/radiegtya/orgs","repos_url":"https://api.github.com/users/radiegtya/repos","events_url":"https://api.github.com/users/radiegtya/events{/privacy}","received_events_url":"https://api.github.com/users/radiegtya/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-03T03:08:17Z","updated_at":"2016-03-03T04:50:21Z","closed_at":null,"body":"Am I doing it right?\r\nBecause currently I can't set the ds within state, I can only set it on render, so I don't use state like RN ds usually used.\r\n\r\nhere is my code, is this correct way to implement:\r\n```javascript\r\n@connectMeteor\r\nclass MeteorRN extends Component {\r\n\r\n  constructor(){\r\n    super();\r\n\r\n    this.ds = new ListView.DataSource({\r\n      rowHasChanged: (row1, row2) => !_.isEqual(row1, row2),\r\n    });\r\n  }\r\n\r\n  startMeteorSubscriptions() {\r\n    Meteor.subscribe('channels');\r\n  }\r\n\r\n  getMeteorData() {\r\n    //I can't set state here to update DS row like RN best practice, because data here is not valid\r\n     return {\r\n       channels: Meteor.collection('channels').find()\r\n     }\r\n  }\r\n\r\n  _renderRow(rowData){\r\n      return (\r\n        <TouchableHighlight style={styles.row}  underlayColor='#c8c7cc'>\r\n          <Text>{rowData.name}</Text>\r\n        </TouchableHighlight>\r\n      );\r\n  }\r\n\r\n  render(){\r\n    const {channels} = this.data;\r\n\r\n    return (\r\n        <View style={styles.container}>\r\n          <ListView\r\n            dataSource={this.ds.cloneWithRows(channels)}\r\n            renderRow={this._renderRow}\r\n            style={styles.listView}\r\n          />\r\n        </View>\r\n    )\r\n  }\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/comments/191581358","html_url":"https://github.com/inProgress-team/react-native-meteor/issues/13#issuecomment-191581358","issue_url":"https://api.github.com/repos/inProgress-team/react-native-meteor/issues/13","id":191581358,"user":{"login":"Mokto","id":5103928,"avatar_url":"https://avatars.githubusercontent.com/u/5103928?v=3","gravatar_id":"","url":"https://api.github.com/users/Mokto","html_url":"https://github.com/Mokto","followers_url":"https://api.github.com/users/Mokto/followers","following_url":"https://api.github.com/users/Mokto/following{/other_user}","gists_url":"https://api.github.com/users/Mokto/gists{/gist_id}","starred_url":"https://api.github.com/users/Mokto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mokto/subscriptions","organizations_url":"https://api.github.com/users/Mokto/orgs","repos_url":"https://api.github.com/users/Mokto/repos","events_url":"https://api.github.com/users/Mokto/events{/privacy}","received_events_url":"https://api.github.com/users/Mokto/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T04:50:20Z","updated_at":"2016-03-03T04:50:20Z","body":"Your solution is fine, but not perfect in my opinion.\r\n\r\nBecause you cloneWithRows at each render. In your case it is fine because your class rerender only if channels change, but I might add a listener for data change in startMeteorSubscriptions.\r\n\r\nI have to think about it.\r\n\r\nWhat do you think ?"}}