Skip to content

Commit

Permalink
Merge pull request facebook#8029 from sebmarkbage/fiberreturnfromtopr…
Browse files Browse the repository at this point in the history
…ender

Quick fix to the return top level problem
  • Loading branch information
sebmarkbage authored Oct 21, 2016
2 parents 9b1b40c + 6e7c89e commit 8cac523
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ var ReactDOM = {

render(element : ReactElement<any>, container : DOMContainerElement) {
warnAboutUnstableUse();
let root;
if (!container._reactRootContainer) {
container._reactRootContainer = DOMRenderer.mountContainer(element, container);
root = container._reactRootContainer = DOMRenderer.mountContainer(element, container);
} else {
DOMRenderer.updateContainer(element, container._reactRootContainer);
DOMRenderer.updateContainer(element, root = container._reactRootContainer);
}
return DOMRenderer.getPublicRootInstance(root);
},

unmountComponentAtNode(container : DOMContainerElement) {
Expand Down
15 changes: 10 additions & 5 deletions src/renderers/shared/fiber/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ export type HostConfig<T, P, I, TI, C> = {

type OpaqueNode = Fiber;

export type Reconciler<C> = {
export type Reconciler<C, I> = {
mountContainer(element : ReactElement<any>, containerInfo : C) : OpaqueNode,
updateContainer(element : ReactElement<any>, container : OpaqueNode) : void,
unmountContainer(container : OpaqueNode) : void,
performWithPriority(priorityLevel : PriorityLevel, fn : Function) : void,

// Used to extract the return value from the initial render. Legacy API.
getPublicRootInstance(container : OpaqueNode) : (C | null),
getPublicRootInstance(container : OpaqueNode) : (ReactComponent<any, any, any> | I | null),
};

module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) : Reconciler<C> {
module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) : Reconciler<C, I> {

var { scheduleWork, performWithPriority } = ReactFiberScheduler(config);

Expand Down Expand Up @@ -106,8 +106,13 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) :

performWithPriority,

getPublicRootInstance(container : OpaqueNode) : (C | null) {
return null;
getPublicRootInstance(container : OpaqueNode) : (ReactComponent<any, any, any> | I | null) {
const root : FiberRoot = (container.stateNode : any);
const containerFiber = root.current;
if (!containerFiber.child) {
return null;
}
return containerFiber.child.stateNode;
},

};
Expand Down

0 comments on commit 8cac523

Please sign in to comment.