Skip to content

Commit 5e36329

Browse files
committed
Improve warning message, remove dedup check, and unmock console.error
**what is the change?:** Various changes to get this closer to being finished; - Improved warning message (thanks @spicyj!!!) - Removed dedup check on warning - Remove mocking of 'console.error' in portals test **why make this change?:** - warning message improvement: communicates better with users - Remove dedup check: it wasn't important in this case - Remove mocking of 'console.error'; we don't want to ignore an inaccurate warning, even for an "unstable" feature. **test plan:** `yarn test` -> follow-up commits will fix the remaining tests **issue:** issue #8854
1 parent f072d17 commit 5e36329

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/renderers/dom/fiber/ReactDOMFiberEntry.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,21 +531,19 @@ function renderSubtreeIntoContainer(
531531
);
532532

533533
if (__DEV__) {
534-
let warned;
535-
if (!warned
534+
if (
536535
&& container._reactRootContainer
537536
&& container.nodeType !== COMMENT_NODE) {
538537
const firstChild = container.firstChild;
539538
const hostInstance =
540539
DOMRenderer.findHostInstance(container._reactRootContainer.current);
541540
if (hostInstance) {
542-
warned = true;
543541
warning(
544542
hostInstance.parentNode === container,
545-
'render(...): It looks like the content of this container may have ' +
546-
'been updated or cleared outside of React. ' +
547-
'This can cause errors or failed updates to the container. ' +
548-
'Please call `ReactDOM.render` with your new content.',
543+
'render(...): It looks like the React-rendered content of this ' +
544+
'container was removed without using React. This is not '
545+
'supported and will cause errors. Instead, call ' +
546+
'ReactDOM.unmountComponentAtNode to empty a container.',
549547
);
550548
}
551549
}

src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,6 @@ describe('ReactDOMFiber', () => {
758758
});
759759

760760
it('should update portal context if it changes due to re-render', () => {
761-
// We mock out console error because this causes a warning to fire;
762-
// it looks as if the content should be in the 'container' div,
763-
// and when it's not there after the first render React assumes the
764-
// container was cleared outside of React.
765-
// for now we are not concerned about this warning firing.
766-
spyOn(console, 'error');
767-
768761
var portalContainer = document.createElement('div');
769762

770763
class Component extends React.Component {

0 commit comments

Comments
 (0)