Skip to content

Commit

Permalink
Expose root fiber to DevTools
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jan 14, 2017
1 parent 6a48891 commit ebdc1c1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/renderers/dom/fiber/ReactDOMFiber.js
Expand Up @@ -318,6 +318,9 @@ function warnAboutUnstableUse() {
warned = true;
}

// TODO
let currentRoot;

function renderSubtreeIntoContainer(parentComponent : ?ReactComponent<any, any, any>, children : ReactNodeList, containerNode : DOMContainerElement | Document, callback: ?Function) {
validateContainer(containerNode);

Expand All @@ -331,6 +334,7 @@ function renderSubtreeIntoContainer(parentComponent : ?ReactComponent<any, any,
}
const newRoot = DOMRenderer.createContainer(container);
root = container._reactRootContainer = newRoot;
currentRoot = root;
// Initial mount should not be batched.
DOMRenderer.unbatchedUpdates(() => {
DOMRenderer.updateContainer(children, newRoot, parentComponent, callback);
Expand Down Expand Up @@ -385,4 +389,15 @@ var ReactDOM = {

};

/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
getRoot() {
return currentRoot;
}
});
}

module.exports = ReactDOM;

0 comments on commit ebdc1c1

Please sign in to comment.