Skip to content
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
48 changes: 26 additions & 22 deletions packages/react-dom/src/__tests__/ReactDOMFiber-test.js
Original file line number Diff line number Diff line change
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
Loading