okonet / react-container-dimensions

Wrapper component that detects element resize and passes new dimensions down the tree. Based on https://github.com/wnr/element-resize-detector
MIT License
229 stars 26 forks source link

Container height always zero #45

Closed moconnell closed 6 years ago

moconnell commented 6 years ago

I am trying to use react-container-dimensions, but the height is always coming through as zero.

    renderChart() {
        return (
            <div className="candleChart">
                <ContainerDimensions>
                    {({width, height}) =>
                        <CandleStickStockScaleChart width={width} height={height}/>
                    }
                </ContainerDimensions>
            </div>
        );
    }
.candleChart {
    width: 100%;
    height: 50%;
}
CandleStickStockScaleChart.render() - height(0) width(1786.949951171875)
CandleStickStockScaleChart.jsx:151:8

Any ideas?

moconnell commented 6 years ago

Basic CSS issue - I set the outer container to position: absolute; and it now works.