Skip to content

Commit fd6bada

Browse files
committed
[fixed] SSR rendering issue with popup
fixes jquense#304
1 parent 665549d commit fd6bada

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/Popup.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = React.createClass({
4646

4747
getInitialState() {
4848
return {
49+
initialRender: true,
4950
status: this.props.open ? OPENING : CLOSED
5051
}
5152
},
@@ -68,9 +69,14 @@ module.exports = React.createClass({
6869
},
6970

7071
componentDidMount() {
71-
if (this.state.status === OPENING) {
72-
this.open();
73-
}
72+
let isOpen = this.state.status === OPENING;
73+
74+
compat.batchedUpdates(() => {
75+
this.setState({ initialRender: false })
76+
if (isOpen) {
77+
this.open();
78+
}
79+
})
7480
},
7581

7682
componentDidUpdate(pvProps){
@@ -170,7 +176,10 @@ module.exports = React.createClass({
170176
})
171177
},
172178

173-
getOffsetForStatus(status){
179+
getOffsetForStatus(status) {
180+
if (this.state.initialRender)
181+
return {}
182+
174183
let _in = properties('top', this.props.dropUp ? '100%' : '-100%')
175184
, out = properties('top', 0)
176185
return {

src/util/compat.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module.exports = {
1111

1212
findDOMNode(component){
1313
return ReactDOM.findDOMNode(component)
14-
}
14+
},
1515

16+
batchedUpdates(cb) {
17+
ReactDOM.unstable_batchedUpdates(cb)
18+
}
1619
}

0 commit comments

Comments
 (0)