Skip to content

Instantly share code, notes, and snippets.

@peterpme
Created September 11, 2015 21:20
Show Gist options
  • Save peterpme/d0346673cf1a5226dd41 to your computer and use it in GitHub Desktop.
Save peterpme/d0346673cf1a5226dd41 to your computer and use it in GitHub Desktop.
message-view alt weirdness
export default class MessageView extends React.Component {
constructor(props) {
super(props)
let ds = new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2
})
this.state = {
dataSource: ds.cloneWithRows([]),
interlocutorName: null,
video: null,
subject: null,
threads: MessageStore.fetchById(this.props.threadId)
}
}
componentWillMount() {
MessageStore.listen(this.onChange.bind(this))
this.setState({ userId: UserStore.getCurrentUserId() })
console.log('mounted')
}
componentWillUnmount() {
console.log('unmounting')
MessageStore.unlisten(this.onChange.bind(this))
}
onChange(state) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(state.messages),
interlocutorName: state.thread.other_user.name,
video: state.thread.video,
subject: state.thread.subject
})
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment