Skip to content

Commit 1260850

Browse files
committed
[fixed] backward compatibility with previous react versions.
1 parent 45ca9d4 commit 1260850

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"karma-webpack": "^2.0.4",
4848
"mocha": "3.5.3",
4949
"npm-run-all": "^4.1.1",
50-
"react": "^16",
51-
"react-dom": "^16",
50+
"react": "^16.0.0",
51+
"react-dom": "^16.0.0",
5252
"react-router": "^4.2.0",
5353
"react-router-dom": "^4.2.2",
5454
"should": "^13.1.0",

src/components/Modal.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export default class Modal extends Component {
105105

106106
componentDidMount() {
107107
if (!canUseDOM) return;
108+
109+
if (!isReact16) {
110+
this.node = document.createElement('div');
111+
}
108112
this.node.className = this.props.portalClassName;
109113

110114
const parent = getParentElement(this.props.parentSelector);
@@ -164,7 +168,7 @@ export default class Modal extends Component {
164168
}
165169

166170
portalRef = ref => { this.portal = ref; }
167-
171+
168172
renderPortal = props => {
169173
const portal = createPortal(this, (
170174
<ModalPortal defaultStyles={Modal.defaultStyles} {...props} />
@@ -177,10 +181,10 @@ export default class Modal extends Component {
177181
return null;
178182
}
179183

180-
if (!this.node) {
184+
if (!this.node && isReact16) {
181185
this.node = document.createElement('div');
182186
}
183-
187+
184188
return createPortal(
185189
<ModalPortal ref={this.portalRef}
186190
defaultStyles={Modal.defaultStyles}

0 commit comments

Comments
 (0)