Skip to content

Commit

Permalink
Fixes SSR. Closes #134
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed May 2, 2018
1 parent b083b47 commit 320d7a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/sizeMe.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ function sizeMe(config = defaultConfig) {

const refreshDelayStrategy = refreshMode === 'throttle' ? throttle : debounce

const detector = resizeDetector(resizeDetectorStrategy)

return function WrapComponent(WrappedComponent) {
const SizeMeRenderWrapper = renderWrapper(WrappedComponent)

Expand All @@ -187,6 +185,7 @@ function sizeMe(config = defaultConfig) {
}

componentDidMount() {
this.detector = resizeDetector(resizeDetectorStrategy)
this.determineStrategy(this.props)
this.handleDOMNode()
}
Expand All @@ -206,7 +205,7 @@ function sizeMe(config = defaultConfig) {
this.checkIfSizeChanged = () => undefined

if (this.domEl) {
detector.uninstall(this.domEl)
this.detector.uninstall(this.domEl)
this.domEl = null
}
}
Expand Down Expand Up @@ -245,18 +244,18 @@ function sizeMe(config = defaultConfig) {
if (!found) {
// This is for special cases where the element may be null.
if (this.domEl) {
detector.uninstall(this.domEl)
this.detector.uninstall(this.domEl)
this.domEl = null
}
return
}

if (this.domEl) {
detector.uninstall(this.domEl)
this.detector.uninstall(this.domEl)
}

this.domEl = found
detector.listenTo(this.domEl, this.checkIfSizeChanged)
this.detector.listenTo(this.domEl, this.checkIfSizeChanged)
}

refCallback = element => {
Expand Down

0 comments on commit 320d7a2

Please sign in to comment.