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

Add unstable_renderSubtreeIntoContainer and unstable_createPortal feature flags #17880

Merged
merged 2 commits into from Jan 21, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 26 additions & 22 deletions packages/react-dom/src/__tests__/ReactDOMFiber-test.js
Expand Up @@ -13,6 +13,8 @@ const React = require('react');
const ReactDOM = require('react-dom');
const PropTypes = require('prop-types');

const ReactFeatureFlags = require('shared/ReactFeatureFlags');

describe('ReactDOMFiber', () => {
let container;

Expand Down Expand Up @@ -247,30 +249,32 @@ describe('ReactDOMFiber', () => {
});

// TODO: remove in React 17
it('should support unstable_createPortal alias', () => {
const portalContainer = document.createElement('div');
if (!ReactFeatureFlags.disableUnstableCreatePortal) {
it('should support unstable_createPortal alias', () => {
const portalContainer = document.createElement('div');

expect(() =>
ReactDOM.render(
<div>
{ReactDOM.unstable_createPortal(<div>portal</div>, portalContainer)}
</div>,
container,
),
).toWarnDev(
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
'and will be removed in React 17+. Update your code to use ' +
'ReactDOM.createPortal() instead. It has the exact same API, ' +
'but without the "unstable_" prefix.',
{withoutStack: true},
);
expect(portalContainer.innerHTML).toBe('<div>portal</div>');
expect(container.innerHTML).toBe('<div></div>');
expect(() =>
ReactDOM.render(
<div>
{ReactDOM.unstable_createPortal(<div>portal</div>, portalContainer)}
</div>,
container,
),
).toWarnDev(
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
'and will be removed in React 17+. Update your code to use ' +
'ReactDOM.createPortal() instead. It has the exact same API, ' +
'but without the "unstable_" prefix.',
{withoutStack: true},
);
expect(portalContainer.innerHTML).toBe('<div>portal</div>');
expect(container.innerHTML).toBe('<div></div>');

ReactDOM.unmountComponentAtNode(container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
});
ReactDOM.unmountComponentAtNode(container);
expect(portalContainer.innerHTML).toBe('');
expect(container.innerHTML).toBe('');
});
}

it('should render many portals', () => {
const portalContainer1 = document.createElement('div');
Expand Down