From 12608509c4dc99938dcc4223c1899a468535f8f2 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Wed, 4 Oct 2017 13:28:23 -0300 Subject: [PATCH] [fixed] backward compatibility with previous react versions. --- package.json | 4 ++-- src/components/Modal.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 28310536..2d0158a1 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "karma-webpack": "^2.0.4", "mocha": "3.5.3", "npm-run-all": "^4.1.1", - "react": "^16", - "react-dom": "^16", + "react": "^16.0.0", + "react-dom": "^16.0.0", "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "should": "^13.1.0", diff --git a/src/components/Modal.js b/src/components/Modal.js index 027669b9..5a914e4b 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -105,6 +105,10 @@ export default class Modal extends Component { componentDidMount() { if (!canUseDOM) return; + + if (!isReact16) { + this.node = document.createElement('div'); + } this.node.className = this.props.portalClassName; const parent = getParentElement(this.props.parentSelector); @@ -164,7 +168,7 @@ export default class Modal extends Component { } portalRef = ref => { this.portal = ref; } - + renderPortal = props => { const portal = createPortal(this, ( @@ -177,10 +181,10 @@ export default class Modal extends Component { return null; } - if (!this.node) { + if (!this.node && isReact16) { this.node = document.createElement('div'); } - + return createPortal(