sonarr-repo-only/frontend/src/Components/Measure.js

39 lines
606 B
JavaScript
Raw Normal View History

2018-01-13 02:01:27 +00:00
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import ReactMeasure from 'react-measure';
class Measure extends Component {
//
// Lifecycle
componentWillUnmount() {
this.onMeasure.cancel();
}
//
// Listeners
onMeasure = _.debounce((payload) => {
this.props.onMeasure(payload);
2022-05-20 04:15:43 +00:00
}, 250, { leading: true, trailing: false });
2018-01-13 02:01:27 +00:00
//
// Render
render() {
return (
<ReactMeasure
{...this.props}
/>
);
}
}
Measure.propTypes = {
onMeasure: PropTypes.func.isRequired
};
export default Measure;