mirror of
https://github.com/Readarr/Readarr
synced 2025-12-27 18:54:54 +01:00
53 lines
971 B
JavaScript
53 lines
971 B
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import ReactMeasure from 'react-measure';
|
|
|
|
class Measure extends Component {
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onMeasure = (payload) => {
|
|
this.props.onMeasure(payload.bounds);
|
|
};
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
const {
|
|
className,
|
|
style,
|
|
onMeasure,
|
|
children,
|
|
...otherProps
|
|
} = this.props;
|
|
|
|
return (
|
|
<ReactMeasure
|
|
bounds={true}
|
|
onResize={this.onMeasure}
|
|
{...otherProps}
|
|
>
|
|
{({ measureRef }) => (
|
|
<div
|
|
ref={measureRef}
|
|
className={className}
|
|
style={style}
|
|
>
|
|
{children}
|
|
</div>
|
|
)}
|
|
</ReactMeasure>
|
|
);
|
|
}
|
|
}
|
|
|
|
Measure.propTypes = {
|
|
className: PropTypes.string,
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
onMeasure: PropTypes.func.isRequired,
|
|
children: PropTypes.node
|
|
};
|
|
|
|
export default Measure;
|