import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { debounce } from 'lodash'; import classnames from 'classnames'; export default class SignatureRequestMessage extends PureComponent { static propTypes = { data: PropTypes.object.isRequired, onMessageScrolled: PropTypes.func, setMessageRootRef: PropTypes.func, messageRootRef: PropTypes.object, messageIsScrollable: PropTypes.bool, }; static contextTypes = { t: PropTypes.func, }; state = { messageIsScrolled: false, }; setMessageIsScrolled = () => { if (!this.props.messageRootRef || this.state.messageIsScrolled) { return; } const { scrollTop, offsetHeight, scrollHeight } = this.props.messageRootRef; const isAtBottom = scrollTop + offsetHeight >= scrollHeight; if (isAtBottom) { this.setState({ messageIsScrolled: true }); this.props.onMessageScrolled(); } }; onScroll = debounce(this.setMessageIsScrolled, 25); renderNode(data) { return (