chinwagsocial/app/assets/javascripts/components/components/status_list.jsx
Eugen Rochko ef9d4f4e06 Use reselect to memoize denormalization in UI state
Also upgrade react-redux to latest version. This is a performance update
2016-10-08 00:01:22 +02:00

43 lines
1.1 KiB
JavaScript

import Status from './status';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PureRenderMixin from 'react-addons-pure-render-mixin';
const StatusList = React.createClass({
propTypes: {
statuses: ImmutablePropTypes.list.isRequired,
onReply: React.PropTypes.func,
onReblog: React.PropTypes.func,
onFavourite: React.PropTypes.func,
onDelete: React.PropTypes.func,
onScrollToBottom: React.PropTypes.func,
me: React.PropTypes.number
},
mixins: [PureRenderMixin],
handleScroll (e) {
const { scrollTop, scrollHeight, clientHeight } = e.target;
if (scrollTop === scrollHeight - clientHeight) {
this.props.onScrollToBottom();
}
},
render () {
const { statuses, onScrollToBottom, ...other } = this.props;
return (
<div style={{ overflowY: 'scroll', flex: '1 1 auto', overflowX: 'hidden' }} className='scrollable' onScroll={this.handleScroll}>
<div>
{statuses.map((status) => {
return <Status key={status.get('id')} {...other} status={status} />;
})}
</div>
</div>
);
}
});
export default StatusList;