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
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export type HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL> = {
): number,
cancelDeferredCallback(callbackID: number): void,

prepareForCommit(): void,
resetAfterCommit(): void,
prepareForCommit(containerInfo: C): void,
resetAfterCommit(containerInfo: C): void,

now(): number,

Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
firstEffect = finishedWork.firstEffect;
}

prepareForCommit();
prepareForCommit(root.containerInfo);

// Commit all the side-effects within a tree. We'll do this in two passes.
// The first pass performs all the host insertions, updates, deletions and
Expand Down Expand Up @@ -434,7 +434,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
}
stopCommitHostEffectsTimer();

resetAfterCommit();
resetAfterCommit(root.containerInfo);

// The work-in-progress tree is now the current tree. This must come after
// the first pass of the commit phase, so that the previous tree is still
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,52 @@ describe('ReactFiberHostContext', () => {
);
expect(creates).toBe(2);
});

it('should send the context to prepareForCommit and resetAfterCommit', () => {
let rootContext = {};
const Renderer = ReactFiberReconciler({
prepareForCommit: function(hostContext) {
expect(hostContext).toBe(rootContext);
},
resetAfterCommit: function(hostContext) {
expect(hostContext).toBe(rootContext);
},
getRootHostContext: function() {
return null;
},
getChildHostContext: function() {
return null;
},
shouldSetTextContent: function() {
return false;
},
createInstance: function() {
return null;
},
finalizeInitialChildren: function() {
return null;
},
appendInitialChild: function() {
return null;
},
now: function() {
return 0;
},
mutation: {
appendChildToContainer: function() {
return null;
},
},
});

const container = Renderer.createContainer(rootContext);
Renderer.updateContainer(
<a>
<b />
</a>,
container,
/* parentComponent: */ null,
/* callback: */ null,
);
});
});