Open oliviertassinari opened 8 years ago
FWIW, here is how I have reimplemented the same interface:
import React from 'react'
import recompose from 'recompose'
import AutoSize from 'react-virtualized/dist/commonjs/AutoSizer'
export default recompose.createHelper((options = {}) => (Component) => {
const Dimensions = props => (
<AutoSize {...options}>
{(newProps) => {
if (newProps.width === 0 && newProps.height === 0) {
return null
}
const componentProps = { ...props }
if (!options.disableHeight) {
componentProps.containerHeight = newProps.height
}
if (!options.disableWidth) {
componentProps.containerWidth = newProps.width
}
return <Component {...componentProps} />
}}
</AutoSize>
)
return Dimensions
}, 'dimensions')
@digidem Happy to see we go in the same direction:
Would be great to provide the same API than https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md#prop-types (Same implementation / different interface)
One of my use cases is doing the size measurement on a single direction.