Skip to content

Commit 43dd152

Browse files
jsimonsenBrian Stone
authored and
Brian Stone
committed
Support containerStyle option as in previous release
1 parent b2e0ccc commit 43dd152

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

index.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ const React = require('react')
33
const onElementResize = require('element-resize-event')
44
const unbind = require('element-resize-event').unbind
55

6+
const defaultContainerStyle = {
7+
width: '100%',
8+
height: '100%',
9+
padding: 0,
10+
border: 0
11+
}
12+
613
function defaultGetDimensions (element) {
714
return [element.clientWidth, element.clientHeight]
815
}
@@ -74,11 +81,12 @@ function defaultGetDimensions (element) {
7481
* module.exports = Dimensions()(MyComponent) // Enhanced component
7582
*
7683
*/
77-
module.exports = function Dimensions ({
84+
export default function Dimensions ({
7885
getDimensions = defaultGetDimensions,
7986
debounce = 0,
8087
debounceOpts = {},
81-
elementResize = false
88+
elementResize = false,
89+
containerStyle = defaultContainerStyle
8290
} = {}) {
8391
return (ComposedComponent) => {
8492
return class DimensionsHOC extends React.Component {
@@ -165,13 +173,9 @@ module.exports = function Dimensions ({
165173
// only trigger a warning about the wrapper div if we already have a reference to it
166174
console.warn('Wrapper div has no height or width, try overriding style with `containerStyle` option')
167175
}
168-
const wrapperStyle = {
169-
overflow: 'visible',
170-
height: 0,
171-
width: 0
172-
}
176+
173177
return (
174-
<div style={wrapperStyle} ref='wrapper'>
178+
<div style={containerStyle} ref='wrapper'>
175179
{(containerWidth || containerHeight)
176180
? <ComposedComponent
177181
{...this.state}

0 commit comments

Comments
 (0)