Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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