Skip to content

Commit

Permalink
[fixed] SSR rendering issue with popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Feb 7, 2016
1 parent 665549d commit fd6bada
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/Popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = React.createClass({

getInitialState() {
return {
initialRender: true,
status: this.props.open ? OPENING : CLOSED
}
},
Expand All @@ -68,9 +69,14 @@ module.exports = React.createClass({
},

componentDidMount() {
if (this.state.status === OPENING) {
this.open();
}
let isOpen = this.state.status === OPENING;

compat.batchedUpdates(() => {
this.setState({ initialRender: false })
if (isOpen) {
this.open();
}
})
},

componentDidUpdate(pvProps){
Expand Down Expand Up @@ -170,7 +176,10 @@ module.exports = React.createClass({
})
},

getOffsetForStatus(status){
getOffsetForStatus(status) {
if (this.state.initialRender)
return {}

let _in = properties('top', this.props.dropUp ? '100%' : '-100%')
, out = properties('top', 0)
return {
Expand Down
5 changes: 4 additions & 1 deletion src/util/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = {

findDOMNode(component){
return ReactDOM.findDOMNode(component)
}
},

batchedUpdates(cb) {
ReactDOM.unstable_batchedUpdates(cb)
}
}

0 comments on commit fd6bada

Please sign in to comment.