Skip to content

Commit

Permalink
Manual touch ups
Browse files Browse the repository at this point in the history
A few manual changes I made after the codemod ran.
  • Loading branch information
acdlite committed Sep 26, 2021
1 parent a889e82 commit ae033c5
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 55 deletions.
2 changes: 0 additions & 2 deletions packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ export function appendInitialChild(parentInstance, child) {
if (typeof child === 'string') {
// Noop for string children of Text (eg <Text>{'foo'}{'bar'}</Text>)
throw new Error('Text children should already be flattened.');

return;
}

child.inject(parentInstance);
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/client/ReactDOMTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ export function initWrapperState(element: Element, props: Object) {
}

if (isArray(children)) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(children.length <= 1)
if (children.length > 1) {
throw new Error('<textarea> can only have at most one child.');
}
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,6 @@ function pushStartTextArea(
}

if (isArray(children)) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(children.length <= 1)
if (children.length > 1) {
throw new Error('<textarea> can only have at most one child.');
}
Expand Down
4 changes: 0 additions & 4 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,6 @@ class ReactDOMServerRenderer {
} catch (err) {
if (err != null && typeof err.then === 'function') {
if (enableSuspenseServerRenderer) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(this.suspenseDepth > 0)
if (this.suspenseDepth <= 0) {
throw new Error(
// TODO: include component name. This is a bit tricky with current factoring.
Expand Down Expand Up @@ -1477,8 +1475,6 @@ class ReactDOMServerRenderer {
}

if (isArray(textareaChildren)) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(textareaChildren.length <= 1)
if (textareaChildren.length > 1) {
throw new Error('<textarea> can only have at most one child.');
}
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/server/ReactPartialRendererHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,6 @@ function dispatchAction<A>(
queue: UpdateQueue<A>,
action: A,
) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
'Too many re-renders. React limits the number of renders to prevent ' +
Expand Down
2 changes: 0 additions & 2 deletions packages/react-dom/src/server/ReactThreadIDAllocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ function growThreadCountAndReturnNextAvailable() {
const oldSize = oldArray.length;
const newSize = oldSize * 2;

// FIXME: Review this condition before merging
// Should be equivalent to: !(newSize <= 0x10000)
if (newSize > 0x10000) {
throw new Error(
'Maximum number of concurrent React renderers exceeded. ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ function insertSubviewAtIndex(parent, child, index) {
);
}

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

// FIXME: Review this condition before merging
// Should be equivalent to: !(index >= 0)
if (index < 0) {
throw new Error(`Missing view ${child} during removal`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ function recomputePluginOrdering(): void {
const pluginModule = namesToPlugins[pluginName];
const pluginIndex = eventPluginOrder.indexOf(pluginName);

// FIXME: Review this condition before merging
// Should be equivalent to: !(pluginIndex > -1)
if (pluginIndex <= -1) {
throw new Error(
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
Expand Down
6 changes: 4 additions & 2 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ function coerceRef(
'bug in React. Please file an issue.',
);
}
// Assigning this to a const so Flow knows it won't change in the closure
const resolvedInst = inst;

const stringRef = '' + mixedRef;
// Check if previous string ref matches new string ref
Expand All @@ -181,10 +183,10 @@ function coerceRef(
return current.ref;
}
const ref = function(value) {
let refs = inst.refs;
let refs = resolvedInst.refs;
if (refs === emptyRefsObject) {
// This is a lazy pooled frozen object, so we need to initialize.
refs = inst.refs = {};
refs = resolvedInst.refs = {};
}
if (value === null) {
delete refs[stringRef];
Expand Down
6 changes: 4 additions & 2 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ function coerceRef(
'bug in React. Please file an issue.',
);
}
// Assigning this to a const so Flow knows it won't change in the closure
const resolvedInst = inst;

const stringRef = '' + mixedRef;
// Check if previous string ref matches new string ref
Expand All @@ -181,10 +183,10 @@ function coerceRef(
return current.ref;
}
const ref = function(value) {
let refs = inst.refs;
let refs = resolvedInst.refs;
if (refs === emptyRefsObject) {
// This is a lazy pooled frozen object, so we need to initialize.
refs = inst.refs = {};
refs = resolvedInst.refs = {};
}
if (value === null) {
delete refs[stringRef];
Expand Down
2 changes: 0 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ export function renderWithHooks<Props, SecondArg>(
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;

// FIXME: Review this condition before merging
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
'Too many re-renders. React limits the number of renders to prevent ' +
Expand Down
2 changes: 0 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ export function renderWithHooks<Props, SecondArg>(
do {
didScheduleRenderPhaseUpdateDuringThisPass = false;

// FIXME: Review this condition before merging
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
'Too many re-renders. React limits the number of renders to prevent ' +
Expand Down
10 changes: 4 additions & 6 deletions packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ function findHostInstance(component: Object): PublicInstance | null {
if (typeof component.render === 'function') {
throw new Error('Unable to find node on an unmounted component.');
} else {
const keys = Object.keys(component).join(',');
throw new Error(
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
component,
)}`,
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
);
}
}
Expand All @@ -178,10 +177,9 @@ function findHostInstanceWithWarning(
if (typeof component.render === 'function') {
throw new Error('Unable to find node on an unmounted component.');
} else {
const keys = Object.keys(component).join(',');
throw new Error(
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
component,
)}`,
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions packages/react-reconciler/src/ReactFiberReconciler.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ function findHostInstance(component: Object): PublicInstance | null {
if (typeof component.render === 'function') {
throw new Error('Unable to find node on an unmounted component.');
} else {
const keys = Object.keys(component).join(',');
throw new Error(
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
component,
)}`,
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
);
}
}
Expand All @@ -178,10 +177,9 @@ function findHostInstanceWithWarning(
if (typeof component.render === 'function') {
throw new Error('Unable to find node on an unmounted component.');
} else {
const keys = Object.keys(component).join(',');
throw new Error(
`Argument appears to not be a ReactComponent. Keys: ${Object.keys(
component,
)}`,
`Argument appears to not be a ReactComponent. Keys: ${keys}`,
);
}
}
Expand Down
14 changes: 2 additions & 12 deletions packages/react-reconciler/src/ReactTestSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
}
break;
default:
if (!null) {
throw new Error(`Invalid selector type ${selector} specified.`);
}

break;
throw new Error('Invalid selector type specified.');
}

return false;
Expand All @@ -207,14 +203,8 @@ function selectorToString(selector: Selector): string | null {
case TEST_NAME_TYPE:
return `[data-testname="${((selector: any): TestNameSelector).value}"]`;
default:
if (!null) {
throw new Error(`Invalid selector type ${selector} specified.`);
}
break;
throw new Error('Invalid selector type specified.');
}
return null;
}
function findPaths(root: Fiber, selectors: Array<Selector>): Array<Fiber> {
Expand Down
2 changes: 0 additions & 2 deletions packages/react-server/src/ReactFizzHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ function dispatchAction<A>(
queue: UpdateQueue<A>,
action: A,
) {
// FIXME: Review this condition before merging
// Should be equivalent to: !(numberOfReRenders < RE_RENDER_LIMIT)
if (numberOfReRenders >= RE_RENDER_LIMIT) {
throw new Error(
'Too many re-renders. React limits the number of renders to prevent ' +
Expand Down
2 changes: 1 addition & 1 deletion scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
"362": "Could not find React container within specified host subtree.",
"363": "Test selector API is not supported by this renderer.",
"364": "Invalid host root specified. Should be either a React container or a node with a testname attribute.",
"365": "Invalid selector type %s specified.",
"365": "Invalid selector type specified.",
"366": "ReactDOM.createEventHandle: setListener called on an target that did not have a corresponding root. This is likely a bug in React.",
"367": "ReactDOM.createEventHandle: setListener called on an element target that is not managed by React. Ensure React rendered the DOM element.",
"368": "ReactDOM.createEventHandle: setListener called on an invalid target. Provide a valid EventTarget or an element managed by React.",
Expand Down

0 comments on commit ae033c5

Please sign in to comment.