import React from 'react';
import PropTypes from 'prop-types';
import PagedCombatLog from './paged_combat_log.jsx';
class CombatLog extends React.Component {
constructor(props) {
super(props);
this.state = {
start: props.start || 0,
length: props.length || 20,
fetch: null
};
}
componentDidUpdate() {
this.state.fetch();
}
render() {
let ButtonHeader = this.buttonHeader.bind(this);
return (
);
}
buttonHeader() {
return (
);
}
increment() {
this.setState({
start: this.state.start + this.state.length
});
}
decrement() {
this.setState({
start: Math.max(0, this.state.start - this.state.length)
});
}
//bound callbacks
getFetch(fn) {
this.setState({ fetch: fn });
}
onReceived(data) {
if (data.length === 0) {
this.decrement();
}
}
}
CombatLog.propTypes = {
username: PropTypes.string.isRequired
};
export default CombatLog;