import React from 'react'; import PropTypes from 'prop-types'; import PTRComponent from 'react-simple-pull-to-refresh'; import LoadingSpinner from 'soapbox/components/loading_spinner'; /** * PullToRefresh: * Wrapper around a third-party PTR component with Soapbox defaults. */ export default class PullToRefresh extends React.Component { static propTypes = { children: PropTypes.node.isRequired, onRefresh: PropTypes.func, } handleRefresh = () => { const { onRefresh } = this.props; if (onRefresh) { return onRefresh(); } else { // If not provided, do nothing return new Promise(resolve => resolve()); } } render() { const { children, onRefresh, ...rest } = this.props; return ( : null} pullDownThreshold={67} maxPullDownDistance={95} resistance={2} {...rest} > {children} ); } }