@samitouri / QOS-React / commits / 81537c3e51

Rename input -> props

I tried to be clever and generalize it but this is currently only props and there are other assumptions that might break down if it isn't.

Sebastian Markbage committed Jun 11, 2016 at 16:22 UTC 81537c3e511c9e35200b39c1f61a6bef79afbc8a
5 files changed +23 -23
src/renderers/shared/fiber/ReactChildFiber.js
+2 -2
@@ -42,7 +42,7 @@ function createSubsequentChild(parent : Fiber, existingChild : ?Fiber, previousS
42 // TODO: This is not sufficient since previous siblings could be new.
43 // Will fix reconciliation properly later.
44 const clone = ReactFiber.cloneFiber(existingChild);
45 - clone.input = element.props;
45 + clone.pendingProps = element.props;
46 clone.child = existingChild.child;
47 clone.sibling = null;
48 previousSibling.sibling = clone;
@@ -104,7 +104,7 @@ function createFirstChild(parent, existingChild, newChildren) {
104 element.key === existingChild.key) {
105 // Get the clone of the existing fiber.
106 const clone = ReactFiber.cloneFiber(existingChild);
107 - clone.input = element.props;
107 + clone.pendingProps = element.props;
108 clone.child = existingChild.child;
109 clone.sibling = null;
110 return clone;
src/renderers/shared/fiber/ReactFiber.js
+7 -7
@@ -66,9 +66,9 @@ export type Fiber = Instance & {
66 ref: null | (handle : ?Object) => void,
67
68 // Input is the data coming into process this fiber. Arguments. Props.
69 - input: any, // This type will be more specific once we overload the tag.
70 - // TODO: I think that there is a way to merge input and memoizedInput somehow.
71 - memoizedInput: any, // The input used to create the output.
69 + pendingProps: any, // This type will be more specific once we overload the tag.
70 + // TODO: I think that there is a way to merge input and memoizedProps somehow.
71 + memoizedProps: any, // The input used to create the output.
72 // Output is the return value of this fiber, or a linked list of return values
73 // if this returns multiple values. Such as a fragment.
74 output: any, // This type will be more specific once we overload the tag.
@@ -105,8 +105,8 @@ var createFiber = function(tag : TypeOfWork, key : null | string) : Fiber {
105
106 ref: null,
107
108 - input: null,
109 - memoizedInput: null,
108 + pendingProps: null,
109 + memoizedProps: null,
110 output: null,
111
112 pendingWorkPriority: 0,
@@ -149,7 +149,7 @@ exports.cloneFiber = function(fiber : Fiber) : Fiber {
149
150 exports.createFiberFromElement = function(element : ReactElement) {
151 const fiber = exports.createFiberFromElementType(element.type, element.key);
152 - fiber.input = element.props;
152 + fiber.pendingProps = element.props;
153 return fiber;
154 };
155
@@ -175,7 +175,7 @@ exports.createFiberFromElementType = function(type : mixed, key : null | string)
175 exports.createFiberFromCoroutine = function(coroutine : ReactCoroutine) {
176 const fiber = createFiber(CoroutineComponent, coroutine.key);
177 fiber.type = coroutine.handler;
178 - fiber.input = coroutine;
178 + fiber.pendingProps = coroutine;
179 return fiber;
180 };
181
src/renderers/shared/fiber/ReactFiberBeginWork.js
+10 -10
@@ -37,22 +37,22 @@ function reconcileChildren(current, workInProgress, nextChildren) {
37
38 function updateFunctionalComponent(current, workInProgress) {
39 var fn = workInProgress.type;
40 - var props = workInProgress.input;
40 + var props = workInProgress.pendingProps;
41 console.log('update fn:', fn.name);
42 var nextChildren = fn(props);
43 reconcileChildren(current, workInProgress, nextChildren);
44 }
45
46 function updateHostComponent(current, workInProgress) {
47 - console.log('host component', workInProgress.type, typeof workInProgress.input.children === 'string' ? workInProgress.input.children : '');
47 + console.log('host component', workInProgress.type, typeof workInProgress.pendingProps.children === 'string' ? workInProgress.pendingProps.children : '');
48
49 - var nextChildren = workInProgress.input.children;
49 + var nextChildren = workInProgress.pendingProps.children;
50 reconcileChildren(current, workInProgress, nextChildren);
51 }
52
53 function mountIndeterminateComponent(current, workInProgress) {
54 var fn = workInProgress.type;
55 - var props = workInProgress.input;
55 + var props = workInProgress.pendingProps;
56 var value = fn(props);
57 if (typeof value === 'object' && value && typeof value.render === 'function') {
58 console.log('performed work on class:', fn.name);
@@ -67,7 +67,7 @@ function mountIndeterminateComponent(current, workInProgress) {
67 }
68
69 function updateCoroutineComponent(current, workInProgress) {
70 - var coroutine = (workInProgress.input : ?ReactCoroutine);
70 + var coroutine = (workInProgress.pendingProps : ?ReactCoroutine);
71 if (!coroutine) {
72 throw new Error('Should be resolved by now');
73 }
@@ -80,18 +80,18 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
80 // Ideally nothing should rely on this, but relying on it here
81 // means that we don't need an additional field on the work in
82 // progress.
83 - if (current && workInProgress.input === current.memoizedInput) {
83 + if (current && workInProgress.pendingProps === current.memoizedProps) {
84 // The most likely scenario is that the previous copy of the tree contains
85 - // the same input as the new one. In that case, we can just copy the output
85 + // the same props as the new one. In that case, we can just copy the output
86 // and children from that node.
87 workInProgress.output = current.output;
88 workInProgress.child = current.child;
89 workInProgress.stateNode = current.stateNode;
90 return null;
91 }
92 - if (workInProgress.input === workInProgress.memoizedInput) {
92 + if (workInProgress.pendingProps === workInProgress.memoizedProps) {
93 // In a ping-pong scenario, this version could actually contain the
94 - // old input. In that case, we can just bail out.
94 + // old props. In that case, we can just bail out.
95 return null;
96 }
97 switch (workInProgress.tag) {
@@ -102,7 +102,7 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
102 updateFunctionalComponent(current, workInProgress);
103 return workInProgress.child;
104 case ClassComponent:
105 - console.log('class component', workInProgress.input.type.name);
105 + console.log('class component', workInProgress.pendingProps.type.name);
106 return workInProgress.child;
107 case HostComponent:
108 updateHostComponent(current, workInProgress);
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+3 -3
@@ -34,7 +34,7 @@ function transferOutput(child : ?Fiber, parent : Fiber) {
34 // avoid unnecessary traversal. When we have multiple output, we just pass
35 // the linked list of fibers that has the individual output values.
36 parent.output = (child && !child.sibling) ? child.output : child;
37 - parent.memoizedInput = parent.input;
37 + parent.memoizedProps = parent.pendingProps;
38 }
39
40 function recursivelyFillYields(yields, output : ?Fiber | ?ReifiedYield) {
@@ -55,7 +55,7 @@ function recursivelyFillYields(yields, output : ?Fiber | ?ReifiedYield) {
55 }
56
57 function moveCoroutineToHandlerPhase(current : ?Fiber, workInProgress : Fiber) {
58 - var coroutine = (workInProgress.input : ?ReactCoroutine);
58 + var coroutine = (workInProgress.pendingProps : ?ReactCoroutine);
59 if (!coroutine) {
60 throw new Error('Should be resolved by now');
61 }
@@ -104,7 +104,7 @@ exports.completeWork = function(current : ?Fiber, workInProgress : Fiber) : ?Fib
104 console.log('/host component', workInProgress.type);
105 return null;
106 case CoroutineComponent:
107 - console.log('/coroutine component', workInProgress.input.handler.name);
107 + console.log('/coroutine component', workInProgress.pendingProps.handler.name);
108 return moveCoroutineToHandlerPhase(current, workInProgress);
109 case CoroutineHandlerPhase:
110 transferOutput(workInProgress.stateNode, workInProgress);
src/renderers/shared/fiber/ReactFiberReconciler.js
+1 -1
@@ -134,7 +134,7 @@ module.exports = function<T, P, I>(config : HostConfig<T, P, I>) : Reconciler {
134 // is passed. Should be doable though. Might require a wrapper don't know.
135 if (rootFiber && rootFiber.type === element.type && rootFiber.key === element.key) {
136 nextUnitOfWork = ReactFiber.cloneFiber(rootFiber);
137 - nextUnitOfWork.input = element.props;
137 + nextUnitOfWork.pendingProps = element.props;
138 return {};
139 }
140