Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react] Support 16.0.0-alpha.13 #7218

Merged
merged 1 commit into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AppContainer } from 'react-hot-loader';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import React from 'react';
import ReactPerf from 'react-addons-perf';
import { render } from 'react-dom';
import App from 'docs/src/components/App';

Expand All @@ -16,8 +15,6 @@ import App from 'docs/src/components/App';
// a11y(React, { includeSrcNode: true, ReactDOM });
// }

window.Perf = ReactPerf;

const docs = (state = { dark: false }, action) => {
if (action.type === 'TOGGLE_THEME_SHADE') {
return {
Expand Down
1 change: 0 additions & 1 deletion docs/webpack.dll.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const deps = [
'react-hot-loader/patch',
'eventsource-polyfill',
'webpack-dev-server/client',
'react-addons-perf',
'webpack/hot/log-apply-result',
'webpack-dev-server/client/index',
]
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"publish": "npm run build && cd build && npm publish --tag next"
},
"peerDependencies": {
"react": "^15.3.0",
"react-dom": "^15.3.0"
"react": "^15.3.0 || ^16.0.0-alpha.13",
"react-dom": "^15.3.0 || ^16.0.0-alpha.13"
},
"dependencies": {
"babel-runtime": "^6.23.0",
Expand Down Expand Up @@ -128,7 +128,6 @@
"raw-loader": "^0.5.1",
"react": "^15.6.1",
"react-a11y": "^0.3.4",
"react-addons-perf": "^15.4.2",
"react-docgen": "^3.0.0-beta4",
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1",
Expand Down
45 changes: 29 additions & 16 deletions src/internal/Portal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @flow weak

import React, { Component } from 'react';
import { Component, Children } from 'react';
import PropTypes from 'prop-types';
import {
unstable_renderSubtreeIntoContainer, // eslint-disable-line camelcase
unmountComponentAtNode,
} from 'react-dom';
import ReactDOM from 'react-dom';

class Portal extends Component {
static defaultProps = {
Expand All @@ -27,47 +24,63 @@ class Portal extends Component {
layer = null;

getLayer() {
if (!this.layer) {
this.layer = document.createElement('div');
this.layer.setAttribute('data-mui-portal', 'true');
if (document.body) {
document.body.appendChild(this.layer);
}
}

return this.layer;
}

unrenderLayer() {
// Support [email protected]
if (ReactDOM.unstable_createPortal) {
return;
}
if (!this.layer) {
return;
}
unmountComponentAtNode(this.layer);
ReactDOM.unmountComponentAtNode(this.layer);
if (document.body) {
document.body.removeChild(this.layer);
}
this.layer = null;
}

renderLayer() {
// Support [email protected]
if (ReactDOM.unstable_createPortal) {
return;
}

const { children, open } = this.props;

if (open) {
if (!this.layer) {
this.layer = document.createElement('div');
this.layer.setAttribute('data-mui-portal', 'true');
if (document.body) {
document.body.appendChild(this.layer);
}
}

/**
* By calling this method in componentDidMount() and
* componentDidUpdate(), you're effectively creating a "wormhole" that
* funnels React's hierarchical updates through to a DOM node on an
* entirely different part of the page.
*/

const layerElement = React.Children.only(children);
unstable_renderSubtreeIntoContainer(this, layerElement, this.layer);
const layerElement = Children.only(children);
ReactDOM.unstable_renderSubtreeIntoContainer(this, layerElement, this.getLayer());
} else {
this.unrenderLayer();
}
}

render() {
const { children, open } = this.props;

// Support [email protected]
if (ReactDOM.unstable_createPortal && open) {
return ReactDOM.unstable_createPortal(children, this.getLayer());
}

return null;
}
}
Expand Down
95 changes: 0 additions & 95 deletions test/integration/fixtures/perf/TimeWaster.js

This file was deleted.

7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5048,13 +5048,6 @@ react-a11y@^0.3.4:
dependencies:
object.assign "^4.0.3"

react-addons-perf@^15.4.2:
version "15.4.2"
resolved "https://registry.yarnpkg.com/react-addons-perf/-/react-addons-perf-15.4.2.tgz#110bdcf5c459c4f77cb85ed634bcd3397536383b"
dependencies:
fbjs "^0.8.4"
object-assign "^4.1.0"

react-docgen@^3.0.0-beta4:
version "3.0.0-beta5"
resolved "https://registry.yarnpkg.com/react-docgen/-/react-docgen-3.0.0-beta5.tgz#1ae8e506f3608ef00ef1521e29ba61298605b4b1"
Expand Down