@samitouri / QOS-React / commits / a05d1abee8

Minor style tweaks

Dan Abramov committed Nov 11, 2016 at 21:17 UTC a05d1abee8418c568ceabfdb846d5418c54edd20
1 file changed +21 -20
src/renderers/shared/fiber/ReactFiberClassComponent.js
+21 -20
@@ -109,10 +109,11 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
109 return true;
110 }
111
112 - function checkClassInstance(workInProgress: Fiber, inst: any) {
112 + function checkClassInstance(workInProgress: Fiber) {
113 + const instance = workInProgress.stateNode;
114 if (__DEV__) {
115 const name = getComponentName(workInProgress);
115 - const renderPresent = inst.render;
116 + const renderPresent = instance.render;
117 warning(
118 renderPresent,
119 '%s(...): No `render` method found on the returned component ' +
@@ -120,8 +121,8 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
121 name
122 );
123 const noGetInitialStateOnES6 = (
123 - !inst.getInitialState ||
124 - inst.getInitialState.isReactClassApproved
124 + !instance.getInitialState ||
125 + instance.getInitialState.isReactClassApproved
126 );
127 warning(
128 noGetInitialStateOnES6,
@@ -131,8 +132,8 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
132 name
133 );
134 const noGetDefaultPropsOnES6 = (
134 - !inst.getDefaultProps ||
135 - inst.getDefaultProps.isReactClassApproved
135 + !instance.getDefaultProps ||
136 + instance.getDefaultProps.isReactClassApproved
137 );
138 warning(
139 noGetDefaultPropsOnES6,
@@ -141,21 +142,21 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
142 'Use a static property to define defaultProps instead.',
143 name
144 );
144 - const noInstancePropTypes = !inst.propTypes;
145 + const noInstancePropTypes = !instance.propTypes;
146 warning(
147 noInstancePropTypes,
148 'propTypes was defined as an instance property on %s. Use a static ' +
149 'property to define propTypes instead.',
150 name,
151 );
151 - const noInstanceContextTypes = !inst.contextTypes;
152 + const noInstanceContextTypes = !instance.contextTypes;
153 warning(
154 noInstanceContextTypes,
155 'contextTypes was defined as an instance property on %s. Use a static ' +
156 'property to define contextTypes instead.',
157 name,
158 );
158 - const noComponentShouldUpdate = typeof inst.componentShouldUpdate !== 'function';
159 + const noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
160 warning(
161 noComponentShouldUpdate,
162 '%s has a method called ' +
@@ -164,7 +165,7 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
165 'expected to return a value.',
166 name
167 );
167 - const noComponentDidUnmount = typeof inst.componentDidUnmount !== 'function';
168 + const noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
169 warning(
170 noComponentDidUnmount,
171 '%s has a method called ' +
@@ -172,7 +173,7 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
173 'Did you mean componentWillUnmount()?',
174 name
175 );
175 - const noComponentWillRecieveProps = typeof inst.componentWillRecieveProps !== 'function';
176 + const noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
177 warning(
178 noComponentWillRecieveProps,
179 '%s has a method called ' +
@@ -181,15 +182,15 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
182 );
183 }
184
184 - const instanceState = inst.state;
185 - if (instanceState && (typeof instanceState !== 'object' || isArray(instanceState))) {
185 + const state = instance.state;
186 + if (state && (typeof state !== 'object' || isArray(state))) {
187 invariant(
188 false,
189 '%s.state: must be set to an object or null',
190 getComponentName(workInProgress)
191 );
192 }
192 - if (typeof inst.getChildContext === 'function') {
193 + if (typeof instance.getChildContext === 'function') {
194 invariant(
195 typeof workInProgress.type.childContextTypes === 'object',
196 '%s.getChildContext(): childContextTypes must be defined in order to ' +
@@ -211,8 +212,8 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
212 const props = workInProgress.pendingProps;
213 const context = getMaskedContext(workInProgress);
214 const instance = new ctor(props, context);
214 - checkClassInstance(workInProgress, instance);
215 adoptClassInstance(workInProgress, instance);
216 + checkClassInstance(workInProgress);
217 return instance;
218 }
219
@@ -319,21 +320,21 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
320
321 // Compute the next state using the memoized state and the update queue.
322 const updateQueue = workInProgress.updateQueue;
322 - const previousState = workInProgress.memoizedState;
323 + const oldState = workInProgress.memoizedState;
324 // TODO: Previous state can be null.
325 let newState;
326 if (updateQueue) {
327 if (!updateQueue.hasUpdate) {
327 - newState = previousState;
328 + newState = oldState;
329 } else {
329 - newState = mergeUpdateQueue(updateQueue, instance, previousState, newProps);
330 + newState = mergeUpdateQueue(updateQueue, instance, oldState, newProps);
331 }
332 } else {
332 - newState = previousState;
333 + newState = oldState;
334 }
335
336 if (oldProps === newProps &&
336 - previousState === newState &&
337 + oldState === newState &&
338 oldContext === newContext &&
339 updateQueue && !updateQueue.isForced) {
340 return false;