@samitouri / QOS-React / commits / 00084f5503

[Fiber] Rudimentary class support

Mostly just to get started with unit testing.

Sebastian Markbage committed Jul 6, 2016 at 13:47 UTC 00084f55038d95365c383c32c994c38b413c4a3c
1 file changed +18 -1
src/renderers/shared/fiber/ReactFiberBeginWork.js
+18 -1
@@ -55,6 +55,22 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>) {
55 workInProgress.pendingWorkPriority = NoWork;
56 }
57
58 + function updateClassComponent(current, workInProgress) {
59 + var props = workInProgress.pendingProps;
60 + if (!workInProgress.stateNode) {
61 + var ctor = workInProgress.type;
62 + console.log('mount class:', workInProgress.type.name);
63 + workInProgress.stateNode = new ctor(props);
64 + } else {
65 + console.log('update class:', workInProgress.type.name);
66 + }
67 + var instance = workInProgress.stateNode;
68 + instance.props = props;
69 + var nextChildren = instance.render();
70 + reconcileChildren(current, workInProgress, nextChildren);
71 + workInProgress.pendingWorkPriority = NoWork;
72 + }
73 +
74 function updateHostComponent(current, workInProgress) {
75 console.log(
76 'host component', workInProgress.type,
@@ -99,6 +115,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>) {
115 if (workInProgress.alternate) {
116 workInProgress.alternate.tag = ClassComponent;
117 }
118 + value = value.render();
119 } else {
120 console.log('performed work on fn:', fn.name);
121 // Proceed under the assumption that this is a functional component
@@ -199,7 +216,7 @@ module.exports = function<T, P, I, C>(config : HostConfig<T, P, I, C>) {
216 updateFunctionalComponent(current, workInProgress);
217 return workInProgress.child;
218 case ClassComponent:
202 - console.log('class component', workInProgress.pendingProps.type.name);
219 + updateClassComponent(current, workInProgress);
220 return workInProgress.child;
221 case HostContainer:
222 reconcileChildren(current, workInProgress, workInProgress.pendingProps);