Skip to content

Commit

Permalink
Add unstable_renderSubtreeIntoContainer and unstable_createPortal fea…
Browse files Browse the repository at this point in the history
…ture flags (#17880)
  • Loading branch information
trueadm authored Jan 21, 2020
1 parent f2fd484 commit c322f59
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 316 deletions.
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

0 comments on commit c322f59

Please sign in to comment.