facebook/react — pull request #2065 by crm416 (2014-08-19 03:51:33+00:00)
Title: Warn when passing invalid containers to renderComponent and unmountComponentAtNode

Resolves #1858 and #2045.

The `hasNonRootReactChild` method checks if the container has a React-rendered child (i.e., is non-empty) with a non-root ID, which is used as the criteria for warning in both `renderComponent` and `unmountComponentAtNode`. Note that there's also a specific warning for when you pass in a root node, rather than a container.

For example, if your markup is:

```html

```

Then you see the following warnings (prepended with method name, `warning`, etc.):

```js
var nonRoot = document.getElementById('non-root');
React.unmountComponentAtNode(nonRoot);
>>> "The node you're attempting to unmount is not a valid React root node, and thus cannot be unmounted."
```

Or:

```js
var root = document.getElementById('root');
React.unmountComponentAtNode(root);
>>> "The node you're attempting to unmount... You may have passed in a React root node as argument, rather than its container."
```

Or:
```js
var root = document.getElementById('root');
React.renderComponent(

, root);
>>> "Replacing React-rendered children with a new root component."
```

The naming here got a little verbose, so I'm open to suggestions. I think the specific warning for passing in a root node as a container is also worth discussing, but I left it in for now as it's easy to remove.