_cleanupPreviousRender(index) {

		index = index || 0; // Default to everything.

		if (this._previouslyRendered && !RLS().haveCleanedPreviousRender) {

			// Only need to do this once per request.
			RLS().haveCleanedPreviousRender = true;

			logger.debug("Removing previous page's React components");

			[].slice.call(
				document.querySelectorAll(`div[${REACT_SERVER_DATA_ATTRIBUTE}]`)
			).forEach((root, i) => {
				if (i >= index) {
					// Since this node has a "data-react-server-root-id"
					// attribute, we can assume that we created it
					// and should destroy it. Destruction means
					// first unmounting from React and then
					// destroying the DOM node.
					ReactDOM.unmountComponentAtNode(root);
					root.parentNode.removeChild(root);
				}
			});

			[].slice.call(
				document.querySelectorAll(`div[${PAGE_CONTAINER_NODE_ID}]`)
			).forEach((root, i) => {
				if (i >= index) {
					// Gotta get rid of our containers,
					// too.  Need to do this _after_
					// killing the elements, since they
					// might live within these containers.
					root.parentNode.removeChild(root);
				}
			});
		}
	}
Cleans up a previous React render in the document. Unmounts all the components and destoys the mounting
DOM node(s) that were created.