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",

This comment has been minimized.

Copy link
@catamphetamine

catamphetamine Oct 5, 2017

@diasbruno If you have added "backward compatibility with previous react versions" via isReact16 flag in this commit why didn't you change

    "react": "^16",
    "react-dom": "^16",

to

    "react": "^14.0.0 || ^15.0.0 || ^16.0.0",
    "react-dom": "^14.0.0 || ^15.0.0 || ^16.0.0",

This comment has been minimized.

Copy link
@diasbruno

diasbruno Oct 5, 2017

Author Collaborator

I didn't know this could be done on the dependency list. I'll check it and if it's correct we can PR this.

"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.