mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
1 parent
5e0ff5f966
commit
81537c3e51
5 files changed
+23
-23
No files matched your search
@@ -42,7 +42,7 @@ function createSubsequentChild(parent : Fiber, existingChild : ?Fiber, previousS
|
||||
// TODO: This is not sufficient since previous siblings could be new.
|
||||
// Will fix reconciliation properly later.
|
||||
const clone = ReactFiber.cloneFiber(existingChild);
|
||||
clone.input = element.props;
|
||||
clone.pendingProps = element.props;
|
||||
clone.child = existingChild.child;
|
||||
clone.sibling = null;
|
||||
previousSibling.sibling = clone;
|
||||
@@ -104,7 +104,7 @@ function createFirstChild(parent, existingChild, newChildren) {
|
||||
element.key === existingChild.key) {
|
||||
// Get the clone of the existing fiber.
|
||||
const clone = ReactFiber.cloneFiber(existingChild);
|
||||
clone.input = element.props;
|
||||
clone.pendingProps = element.props;
|
||||
clone.child = existingChild.child;
|
||||
clone.sibling = null;
|
||||
return clone;
|
||||
|
||||
@@ -66,9 +66,9 @@ export type Fiber = Instance & {
|
||||
ref: null | (handle : ?Object) => void,
|
||||
|
||||
// Input is the data coming into process this fiber. Arguments. Props.
|
||||
input: any, // This type will be more specific once we overload the tag.
|
||||
// TODO: I think that there is a way to merge input and memoizedInput somehow.
|
||||
memoizedInput: any, // The input used to create the output.
|
||||
pendingProps: any, // This type will be more specific once we overload the tag.
|
||||
// TODO: I think that there is a way to merge input and memoizedProps somehow.
|
||||
memoizedProps: any, // The input used to create the output.
|
||||
// Output is the return value of this fiber, or a linked list of return values
|
||||
// if this returns multiple values. Such as a fragment.
|
||||
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 {
|
||||
|
||||
ref: null,
|
||||
|
||||
input: null,
|
||||
memoizedInput: null,
|
||||
pendingProps: null,
|
||||
memoizedProps: null,
|
||||
output: null,
|
||||
|
||||
pendingWorkPriority: 0,
|
||||
@@ -149,7 +149,7 @@ exports.cloneFiber = function(fiber : Fiber) : Fiber {
|
||||
|
||||
exports.createFiberFromElement = function(element : ReactElement) {
|
||||
const fiber = exports.createFiberFromElementType(element.type, element.key);
|
||||
fiber.input = element.props;
|
||||
fiber.pendingProps = element.props;
|
||||
return fiber;
|
||||
};
|
||||
|
||||
@@ -175,7 +175,7 @@ exports.createFiberFromElementType = function(type : mixed, key : null | string)
|
||||
exports.createFiberFromCoroutine = function(coroutine : ReactCoroutine) {
|
||||
const fiber = createFiber(CoroutineComponent, coroutine.key);
|
||||
fiber.type = coroutine.handler;
|
||||
fiber.input = coroutine;
|
||||
fiber.pendingProps = coroutine;
|
||||
return fiber;
|
||||
};
|
||||
|
||||
|
||||
@@ -37,22 +37,22 @@ function reconcileChildren(current, workInProgress, nextChildren) {
|
||||
|
||||
function updateFunctionalComponent(current, workInProgress) {
|
||||
var fn = workInProgress.type;
|
||||
var props = workInProgress.input;
|
||||
var props = workInProgress.pendingProps;
|
||||
console.log('update fn:', fn.name);
|
||||
var nextChildren = fn(props);
|
||||
reconcileChildren(current, workInProgress, nextChildren);
|
||||
}
|
||||
|
||||
function updateHostComponent(current, workInProgress) {
|
||||
console.log('host component', workInProgress.type, typeof workInProgress.input.children === 'string' ? workInProgress.input.children : '');
|
||||
console.log('host component', workInProgress.type, typeof workInProgress.pendingProps.children === 'string' ? workInProgress.pendingProps.children : '');
|
||||
|
||||
var nextChildren = workInProgress.input.children;
|
||||
var nextChildren = workInProgress.pendingProps.children;
|
||||
reconcileChildren(current, workInProgress, nextChildren);
|
||||
}
|
||||
|
||||
function mountIndeterminateComponent(current, workInProgress) {
|
||||
var fn = workInProgress.type;
|
||||
var props = workInProgress.input;
|
||||
var props = workInProgress.pendingProps;
|
||||
var value = fn(props);
|
||||
if (typeof value === 'object' && value && typeof value.render === 'function') {
|
||||
console.log('performed work on class:', fn.name);
|
||||
@@ -67,7 +67,7 @@ function mountIndeterminateComponent(current, workInProgress) {
|
||||
}
|
||||
|
||||
function updateCoroutineComponent(current, workInProgress) {
|
||||
var coroutine = (workInProgress.input : ?ReactCoroutine);
|
||||
var coroutine = (workInProgress.pendingProps : ?ReactCoroutine);
|
||||
if (!coroutine) {
|
||||
throw new Error('Should be resolved by now');
|
||||
}
|
||||
@@ -80,18 +80,18 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
|
||||
// Ideally nothing should rely on this, but relying on it here
|
||||
// means that we don't need an additional field on the work in
|
||||
// progress.
|
||||
if (current && workInProgress.input === current.memoizedInput) {
|
||||
if (current && workInProgress.pendingProps === current.memoizedProps) {
|
||||
// The most likely scenario is that the previous copy of the tree contains
|
||||
// the same input as the new one. In that case, we can just copy the output
|
||||
// the same props as the new one. In that case, we can just copy the output
|
||||
// and children from that node.
|
||||
workInProgress.output = current.output;
|
||||
workInProgress.child = current.child;
|
||||
workInProgress.stateNode = current.stateNode;
|
||||
return null;
|
||||
}
|
||||
if (workInProgress.input === workInProgress.memoizedInput) {
|
||||
if (workInProgress.pendingProps === workInProgress.memoizedProps) {
|
||||
// In a ping-pong scenario, this version could actually contain the
|
||||
// old input. In that case, we can just bail out.
|
||||
// old props. In that case, we can just bail out.
|
||||
return null;
|
||||
}
|
||||
switch (workInProgress.tag) {
|
||||
@@ -102,7 +102,7 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
|
||||
updateFunctionalComponent(current, workInProgress);
|
||||
return workInProgress.child;
|
||||
case ClassComponent:
|
||||
console.log('class component', workInProgress.input.type.name);
|
||||
console.log('class component', workInProgress.pendingProps.type.name);
|
||||
return workInProgress.child;
|
||||
case HostComponent:
|
||||
updateHostComponent(current, workInProgress);
|
||||
|
||||
@@ -34,7 +34,7 @@ function transferOutput(child : ?Fiber, parent : Fiber) {
|
||||
// avoid unnecessary traversal. When we have multiple output, we just pass
|
||||
// the linked list of fibers that has the individual output values.
|
||||
parent.output = (child && !child.sibling) ? child.output : child;
|
||||
parent.memoizedInput = parent.input;
|
||||
parent.memoizedProps = parent.pendingProps;
|
||||
}
|
||||
|
||||
function recursivelyFillYields(yields, output : ?Fiber | ?ReifiedYield) {
|
||||
@@ -55,7 +55,7 @@ function recursivelyFillYields(yields, output : ?Fiber | ?ReifiedYield) {
|
||||
}
|
||||
|
||||
function moveCoroutineToHandlerPhase(current : ?Fiber, workInProgress : Fiber) {
|
||||
var coroutine = (workInProgress.input : ?ReactCoroutine);
|
||||
var coroutine = (workInProgress.pendingProps : ?ReactCoroutine);
|
||||
if (!coroutine) {
|
||||
throw new Error('Should be resolved by now');
|
||||
}
|
||||
@@ -104,7 +104,7 @@ exports.completeWork = function(current : ?Fiber, workInProgress : Fiber) : ?Fib
|
||||
console.log('/host component', workInProgress.type);
|
||||
return null;
|
||||
case CoroutineComponent:
|
||||
console.log('/coroutine component', workInProgress.input.handler.name);
|
||||
console.log('/coroutine component', workInProgress.pendingProps.handler.name);
|
||||
return moveCoroutineToHandlerPhase(current, workInProgress);
|
||||
case CoroutineHandlerPhase:
|
||||
transferOutput(workInProgress.stateNode, workInProgress);
|
||||
|
||||
@@ -134,7 +134,7 @@ module.exports = function<T, P, I>(config : HostConfig<T, P, I>) : Reconciler {
|
||||
// is passed. Should be doable though. Might require a wrapper don't know.
|
||||
if (rootFiber && rootFiber.type === element.type && rootFiber.key === element.key) {
|
||||
nextUnitOfWork = ReactFiber.cloneFiber(rootFiber);
|
||||
nextUnitOfWork.input = element.props;
|
||||
nextUnitOfWork.pendingProps = element.props;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user