import React, { Component } from 'react';
import { VirtualScroll } from 'react-virtualized';
import pure from 'pure-render-decorator';
import UserListItem from './UserListItem';
@pure
export default class UserList extends Component {
state = {
height: window.innerHeight - 100
};
componentDidMount() {
window.addEventListener('resize', this.handleResize);
}
componentWillUpdate(nextProps) {
if (nextProps.users.size === this.props.users.size) {
this.list.forceUpdate();
}
}
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}
getRowHeight = index => {
if (index === 0 || index === this.props.users.size + 1) {
return 10;
}
return 24;
};
listRef = el => { this.list = el; };
handleResize = () => this.setState({ height: window.innerHeight - 100 });
renderUser = index => {
const { users } = this.props;
if (index === 0 || index === users.size + 1) {
return ;
}
const { tab, openPrivateChat, select } = this.props;
const user = users.get(index - 1);
return (