Skip to content

Commit

Permalink
[fixed] backward compatibility with previous react versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
diasbruno committed Oct 4, 2017
1 parent 45ca9d4 commit 1260850
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 7 additions & 3 deletions src/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -164,7 +168,7 @@ export default class Modal extends Component {
}

portalRef = ref => { this.portal = ref; }

renderPortal = props => {
const portal = createPortal(this, (
<ModalPortal defaultStyles={Modal.defaultStyles} {...props} />
Expand All @@ -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(
<ModalPortal ref={this.portalRef}
defaultStyles={Modal.defaultStyles}
Expand Down

0 comments on commit 1260850

Please sign in to comment.