diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-04-22 03:05:35 +0900 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-21 20:05:35 +0200 |
commit | 1948f9e767c5c8f7cb52337ce777a61b5ad1a599 (patch) | |
tree | 4d5f3549f6e5fd88340bb3543e1eb2eafc47952c /app/assets/javascripts/components/components/status_list.jsx | |
parent | 27ea2a88c12835b491ea5537f934983470faf781 (diff) |
Remove deprecated features at React v15.5 (#1905)
* Remove deprecated features at React v15.5 - [x] React.PropTypes - [x] react-addons-pure-render-mixin - [x] react-addons-test-utils * Uncommented out & Add browserify_rails options * re-add react-addons-shallow * Fix syntax error from resolve conflicts * follow up 59a77923b368d48c590cd9f4a0c6b73ce972d33f
Diffstat (limited to 'app/assets/javascripts/components/components/status_list.jsx')
-rw-r--r-- | app/assets/javascripts/components/components/status_list.jsx | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/app/assets/javascripts/components/components/status_list.jsx b/app/assets/javascripts/components/components/status_list.jsx index 345944e4d..7ba8bad1d 100644 --- a/app/assets/javascripts/components/components/status_list.jsx +++ b/app/assets/javascripts/components/components/status_list.jsx @@ -1,32 +1,18 @@ import Status from './status'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import PureRenderMixin from 'react-addons-pure-render-mixin'; import { ScrollContainer } from 'react-router-scroll'; +import PropTypes from 'prop-types'; import StatusContainer from '../containers/status_container'; import LoadMore from './load_more'; -const StatusList = React.createClass({ - - propTypes: { - statusIds: ImmutablePropTypes.list.isRequired, - onScrollToBottom: React.PropTypes.func, - onScrollToTop: React.PropTypes.func, - onScroll: React.PropTypes.func, - trackScroll: React.PropTypes.bool, - isLoading: React.PropTypes.bool, - isUnread: React.PropTypes.bool, - hasMore: React.PropTypes.bool, - prepend: React.PropTypes.node, - emptyMessage: React.PropTypes.node - }, - - getDefaultProps () { - return { - trackScroll: true - }; - }, - - mixins: [PureRenderMixin], +class StatusList extends React.PureComponent { + + constructor (props, context) { + super(props, context); + this.handleScroll = this.handleScroll.bind(this); + this.setRef = this.setRef.bind(this); + this.handleLoadMore = this.handleLoadMore.bind(this); + } handleScroll (e) { const { scrollTop, scrollHeight, clientHeight } = e.target; @@ -40,38 +26,38 @@ const StatusList = React.createClass({ } else if (this.props.onScroll) { this.props.onScroll(); } - }, + } componentDidMount () { this.attachScrollListener(); - }, + } componentDidUpdate (prevProps) { if (this.node.scrollTop > 0 && (prevProps.statusIds.size < this.props.statusIds.size && prevProps.statusIds.first() !== this.props.statusIds.first() && !!this._oldScrollPosition)) { this.node.scrollTop = this.node.scrollHeight - this._oldScrollPosition; } - }, + } componentWillUnmount () { this.detachScrollListener(); - }, + } attachScrollListener () { this.node.addEventListener('scroll', this.handleScroll); - }, + } detachScrollListener () { this.node.removeEventListener('scroll', this.handleScroll); - }, + } setRef (c) { this.node = c; - }, + } handleLoadMore (e) { e.preventDefault(); this.props.onScrollToBottom(); - }, + } render () { const { statusIds, onScrollToBottom, trackScroll, isLoading, isUnread, hasMore, prepend, emptyMessage } = this.props; @@ -123,6 +109,23 @@ const StatusList = React.createClass({ } } -}); +} + +StatusList.propTypes = { + statusIds: ImmutablePropTypes.list.isRequired, + onScrollToBottom: PropTypes.func, + onScrollToTop: PropTypes.func, + onScroll: PropTypes.func, + trackScroll: PropTypes.bool, + isLoading: PropTypes.bool, + isUnread: PropTypes.bool, + hasMore: PropTypes.bool, + prepend: PropTypes.node, + emptyMessage: PropTypes.node +}; + +StatusList.defaultProps = { + trackScroll: true +}; export default StatusList; |