1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/frontend/src/Components/Measure.js
Mark McDowall 5894b4fd95 v3 UI
2018-12-29 13:08:43 +01:00

39 lines
605 B
JavaScript

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);
}, 250, { leading: true, trailing: false })
//
// Render
render() {
return (
<ReactMeasure
{...this.props}
/>
);
}
}
Measure.propTypes = {
onMeasure: PropTypes.func.isRequired
};
export default Measure;