Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Merged master
  • Loading branch information
Brian Vaughn committed May 19, 2018
commit 0c99c4c568ea16fec8388bd3c5271c2a8d4b3f79
60 changes: 23 additions & 37 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import type {Fiber} from './ReactFiber';
import type {FiberRoot} from './ReactFiberRoot';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {CapturedValue, CapturedError} from './ReactCapturedValue';
import type {ProfilerTimer} from './ReactProfilerTimer';

import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
import {getCommitTime} from './ReactProfilerTimer';
import {
ClassComponent,
HostRoot,
Expand Down Expand Up @@ -112,24 +112,13 @@ export function logError(boundary: Fiber, errorInfo: CapturedValue<mixed>) {
}
}

export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
captureError: (failedFiber: Fiber, error: mixed) => void,
scheduleWork: (
fiber: Fiber,
startTime: ExpirationTime,
expirationTime: ExpirationTime,
) => void,
computeExpirationForFiber: (
startTime: ExpirationTime,
fiber: Fiber,
) => ExpirationTime,
markLegacyErrorBoundaryAsFailed: (instance: mixed) => void,
recalculateCurrentTime: () => ExpirationTime,
profilerTimer: ProfilerTimer,
) {
const {getPublicInstance, mutation, persistence} = config;
const {getCommitTime} = profilerTimer;
const callComponentWillUnmountWithTimer = function(current, instance) {
startPhaseTimer(current, 'componentWillUnmount');
instance.props = current.memoizedProps;
instance.state = current.memoizedState;
instance.componentWillUnmount();
stopPhaseTimer();
};

// Capture errors so they don't interrupt unmounting.
function safelyCallComponentWillUnmount(current, instance) {
Expand Down Expand Up @@ -774,24 +763,19 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
// For hydration we reuse the update path but we treat the oldProps
// as the newProps. The updatePayload will contain the real change in
// this case.
const oldText: string =
current !== null ? current.memoizedProps : newText;
commitTextUpdate(textInstance, oldText, newText);
return;
}
case HostRoot: {
return;
}
case Profiler: {
if (enableProfilerTimer) {
const onRender = finishedWork.memoizedProps.onRender;
onRender(
finishedWork.memoizedProps.id,
current === null ? 'mount' : 'update',
finishedWork.stateNode.duration,
finishedWork.treeBaseTime,
finishedWork.stateNode.startTime,
getCommitTime(),
const oldProps = current !== null ? current.memoizedProps : newProps;
const type = finishedWork.type;
// TODO: Type the updateQueue to be specific to host components.
const updatePayload: null | UpdatePayload = (finishedWork.updateQueue: any);
finishedWork.updateQueue = null;
if (updatePayload !== null) {
commitUpdate(
instance,
updatePayload,
type,
oldProps,
newProps,
finishedWork,
);
}
}
Expand Down Expand Up @@ -824,6 +808,8 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
current === null ? 'mount' : 'update',
finishedWork.stateNode.duration,
finishedWork.treeBaseTime,
finishedWork.stateNode.startTime,
getCommitTime(),
);

// Reset actualTime after successful commit.
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.