Skip to content

Commit 60629df

Browse files
authored
Merge pull request #1 from cjsheets/master
Merge cjsheets fix
2 parents d1ff89d + 0c0b4f7 commit 60629df

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
React [higher-order component](https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775) to get the dimensions of a wrapper element and pass them as properties to the child element.
44

5+
**DEVELOPMENT STATUS:** I'm not really using this any more since for grids/tables in React I've switched from [fixed-data-table](https://github.com/facebook/fixed-data-table) (which I was using this for) to [react-virtualized](https://github.com/bvaughn/react-virtualized) which includes similar functionality to this with the [Autosizer](https://bvaughn.github.io/react-virtualized/#/components/AutoSizer). I'm happy for someone else to take this module on.
6+
57
**v2.0.0-alpha1:** Includes several breaking changes, most importantly changing the way dimensions are calculated. The parent container is now used for width calculations, and the wrapper div inside this component is ignored. Hopefully this will solve the multiple styling issues users have had, but it will break layout in apps using v1.2.0
68

79
## Why? How?

index.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const _debounce = require('lodash.debounce')
22
const React = require('react')
33
const onElementResize = require('element-resize-event')
4+
const unbind = require('element-resize-event').unbind
45

56
function defaultGetDimensions (element) {
67
return [element.clientWidth, element.clientHeight]
@@ -139,9 +140,12 @@ module.exports = function Dimensions ({
139140
}
140141

141142
componentWillUnmount () {
142-
this.getWindow().removeEventListener('resize', this.onResize)
143-
// TODO: remote element-resize-event listener.
144-
// pending https://github.com/KyleAMathews/element-resize-event/issues/2
143+
this._parent = this.refs.wrapper.parentNode
144+
if (elementResize) {
145+
unbind(this._parent)
146+
} else {
147+
this.getWindow().removeEventListener('resize', this.onResize)
148+
}
145149
}
146150

147151
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"react-dom": "^0.14.0 || ^15.0.0"
5050
},
5151
"dependencies": {
52-
"element-resize-event": "^2.0.4",
52+
"element-resize-event": "^2.0.8",
5353
"lodash.debounce": "^4.0.6"
5454
}
5555
}

0 commit comments

Comments
 (0)