Skip to content

Commit e93819f

Browse files
committed
Manual touch ups
A few manual changes I made after the codemod ran.
1 parent 4e6bd45 commit e93819f

File tree

18 files changed

+20
-55
lines changed

18 files changed

+20
-55
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ export function appendInitialChild(parentInstance, child) {
248248
if (typeof child === 'string') {
249249
// Noop for string children of Text (eg <Text>{'foo'}{'bar'}</Text>)
250250
throw new Error('Text children should already be flattened.');
251-
252-
return;
253251
}
254252

255253
child.inject(parentInstance);

packages/react-dom/src/client/ReactDOMTextarea.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ export function initWrapperState(element: Element, props: Object) {
104104
}
105105

106106
if (isArray(children)) {
107-
// FIXME: Review this condition before merging
108-
// Should be equivalent to: !(children.length <= 1)
109107
if (children.length > 1) {
110108
throw new Error('<textarea> can only have at most one child.');
111109
}

packages/react-dom/src/server/ReactDOMServerFormatConfig.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,6 @@ function pushStartTextArea(
896896
}
897897

898898
if (isArray(children)) {
899-
// FIXME: Review this condition before merging
900-
// Should be equivalent to: !(children.length <= 1)
901899
if (children.length > 1) {
902900
throw new Error('<textarea> can only have at most one child.');
903901
}

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,6 @@ class ReactDOMServerRenderer {
976976
} catch (err) {
977977
if (err != null && typeof err.then === 'function') {
978978
if (enableSuspenseServerRenderer) {
979-
// FIXME: Review this condition before merging
980-
// Should be equivalent to: !(this.suspenseDepth > 0)
981979
if (this.suspenseDepth <= 0) {
982980
throw new Error(
983981
// TODO: include component name. This is a bit tricky with current factoring.
@@ -1477,8 +1475,6 @@ class ReactDOMServerRenderer {
14771475
}
14781476

14791477
if (isArray(textareaChildren)) {
1480-
// FIXME: Review this condition before merging
1481-
// Should be equivalent to: !(textareaChildren.length <= 1)
14821478
if (textareaChildren.length > 1) {
14831479
throw new Error('<textarea> can only have at most one child.');
14841480
}

packages/react-dom/src/server/ReactPartialRendererHooks.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,6 @@ function dispatchAction<A>(
424424
queue: UpdateQueue<A>,
425425
action: A,
426426
) {
427-
// FIXME: Review this condition before merging
428-
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
429427
if (numberOfReRenders >= RE_RENDER_LIMIT) {
430428
throw new Error(
431429
'Too many re-renders. React limits the number of renders to prevent ' +

packages/react-dom/src/server/ReactThreadIDAllocator.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ function growThreadCountAndReturnNextAvailable() {
2424
const oldSize = oldArray.length;
2525
const newSize = oldSize * 2;
2626

27-
// FIXME: Review this condition before merging
28-
// Should be equivalent to: !(newSize <= 0x10000)
2927
if (newSize > 0x10000) {
3028
throw new Error(
3129
'Maximum number of concurrent React renderers exceeded. ' +

packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const ReactNativeBridgeEventPlugin = {
150150

151151
if (!bubbleDispatchConfig && !directDispatchConfig) {
152152
throw new Error(
153+
// $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque
153154
`Unsupported top level event type "${topLevelType}" dispatched`,
154155
);
155156
}

packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/UIManager.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ function insertSubviewAtIndex(parent, child, index) {
4040
);
4141
}
4242

43-
// FIXME: Review this condition before merging
44-
// Should be equivalent to: !(0 <= index && index <= parentInfo.children.length)
4543
if (0 > index || index > parentInfo.children.length) {
4644
throw new Error(
4745
`Invalid index ${index} for children ${parentInfo.children}`,
@@ -57,8 +55,6 @@ function removeChild(parent, child) {
5755
const childInfo = views.get(child);
5856
const index = parentInfo.children.indexOf(child);
5957

60-
// FIXME: Review this condition before merging
61-
// Should be equivalent to: !(index >= 0)
6258
if (index < 0) {
6359
throw new Error(`Missing view ${child} during removal`);
6460
}

packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ function recomputePluginOrdering(): void {
4444
const pluginModule = namesToPlugins[pluginName];
4545
const pluginIndex = eventPluginOrder.indexOf(pluginName);
4646

47-
// FIXME: Review this condition before merging
48-
// Should be equivalent to: !(pluginIndex > -1)
4947
if (pluginIndex <= -1) {
5048
throw new Error(
5149
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +

packages/react-reconciler/src/ReactChildFiber.new.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ function coerceRef(
169169
'bug in React. Please file an issue.',
170170
);
171171
}
172+
// Assigning this to a const so Flow knows it won't change in the closure
173+
const resolvedInst = inst;
172174

173175
const stringRef = '' + mixedRef;
174176
// Check if previous string ref matches new string ref
@@ -181,10 +183,10 @@ function coerceRef(
181183
return current.ref;
182184
}
183185
const ref = function(value) {
184-
let refs = inst.refs;
186+
let refs = resolvedInst.refs;
185187
if (refs === emptyRefsObject) {
186188
// This is a lazy pooled frozen object, so we need to initialize.
187-
refs = inst.refs = {};
189+
refs = resolvedInst.refs = {};
188190
}
189191
if (value === null) {
190192
delete refs[stringRef];

packages/react-reconciler/src/ReactChildFiber.old.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ function coerceRef(
169169
'bug in React. Please file an issue.',
170170
);
171171
}
172+
// Assigning this to a const so Flow knows it won't change in the closure
173+
const resolvedInst = inst;
172174

173175
const stringRef = '' + mixedRef;
174176
// Check if previous string ref matches new string ref
@@ -181,10 +183,10 @@ function coerceRef(
181183
return current.ref;
182184
}
183185
const ref = function(value) {
184-
let refs = inst.refs;
186+
let refs = resolvedInst.refs;
185187
if (refs === emptyRefsObject) {
186188
// This is a lazy pooled frozen object, so we need to initialize.
187-
refs = inst.refs = {};
189+
refs = resolvedInst.refs = {};
188190
}
189191
if (value === null) {
190192
delete refs[stringRef];

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ export function renderWithHooks<Props, SecondArg>(
435435
do {
436436
didScheduleRenderPhaseUpdateDuringThisPass = false;
437437

438-
// FIXME: Review this condition before merging
439-
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
440438
if (numberOfReRenders >= RE_RENDER_LIMIT) {
441439
throw new Error(
442440
'Too many re-renders. React limits the number of renders to prevent ' +

packages/react-reconciler/src/ReactFiberHooks.old.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ export function renderWithHooks<Props, SecondArg>(
435435
do {
436436
didScheduleRenderPhaseUpdateDuringThisPass = false;
437437

438-
// FIXME: Review this condition before merging
439-
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
440438
if (numberOfReRenders >= RE_RENDER_LIMIT) {
441439
throw new Error(
442440
'Too many re-renders. React limits the number of renders to prevent ' +

packages/react-reconciler/src/ReactFiberReconciler.new.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ function findHostInstance(component: Object): PublicInstance | null {
154154
if (typeof component.render === 'function') {
155155
throw new Error('Unable to find node on an unmounted component.');
156156
} else {
157+
const keys = Object.keys(component).join(',');
157158
throw new Error(
158-
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
159-
component,
160-
)}`,
159+
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
161160
);
162161
}
163162
}
@@ -178,10 +177,9 @@ function findHostInstanceWithWarning(
178177
if (typeof component.render === 'function') {
179178
throw new Error('Unable to find node on an unmounted component.');
180179
} else {
180+
const keys = Object.keys(component).join(',');
181181
throw new Error(
182-
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
183-
component,
184-
)}`,
182+
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
185183
);
186184
}
187185
}

packages/react-reconciler/src/ReactFiberReconciler.old.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ function findHostInstance(component: Object): PublicInstance | null {
154154
if (typeof component.render === 'function') {
155155
throw new Error('Unable to find node on an unmounted component.');
156156
} else {
157+
const keys = Object.keys(component).join(',');
157158
throw new Error(
158-
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
159-
component,
160-
)}`,
159+
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
161160
);
162161
}
163162
}
@@ -178,10 +177,9 @@ function findHostInstanceWithWarning(
178177
if (typeof component.render === 'function') {
179178
throw new Error('Unable to find node on an unmounted component.');
180179
} else {
180+
const keys = Object.keys(component).join(',');
181181
throw new Error(
182-
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
183-
component,
184-
)}`,
182+
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
185183
);
186184
}
187185
}

packages/react-reconciler/src/ReactTestSelectors.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
183183
}
184184
break;
185185
default:
186-
if (!null) {
187-
throw new Error(`Invalid selector type ${selector} specified.`);
188-
}
189-
190-
break;
186+
throw new Error('Invalid selector type specified.');
191187
}
192188

193189
return false;
@@ -207,14 +203,8 @@ function selectorToString(selector: Selector): string | null {
207203
case TEST_NAME_TYPE:
208204
return `[data-testname="${((selector: any): TestNameSelector).value}"]`;
209205
default:
210-
if (!null) {
211-
throw new Error(`Invalid selector type ${selector} specified.`);
212-
}
213-
214-
break;
206+
throw new Error('Invalid selector type specified.');
215207
}
216-
217-
return null;
218208
}
219209
220210
function findPaths(root: Fiber, selectors: Array<Selector>): Array<Fiber> {

packages/react-server/src/ReactFizzHooks.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ function dispatchAction<A>(
407407
queue: UpdateQueue<A>,
408408
action: A,
409409
) {
410-
// FIXME: Review this condition before merging
411-
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
412410
if (numberOfReRenders >= RE_RENDER_LIMIT) {
413411
throw new Error(
414412
'Too many re-renders. React limits the number of renders to prevent ' +

scripts/error-codes/codes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
"362": "Could not find React container within specified host subtree.",
352352
"363": "Test selector API is not supported by this renderer.",
353353
"364": "Invalid host root specified. Should be either a React container or a node with a testname attribute.",
354-
"365": "Invalid selector type %s specified.",
354+
"365": "Invalid selector type specified.",
355355
"366": "ReactDOM.createEventHandle: setListener called on an target that did not have a corresponding root. This is likely a bug in React.",
356356
"367": "ReactDOM.createEventHandle: setListener called on an element target that is not managed by React. Ensure React rendered the DOM element.",
357357
"368": "ReactDOM.createEventHandle: setListener called on an invalid target. Provide a valid EventTarget or an element managed by React.",

0 commit comments

Comments
 (0)