Skip to content

Commit 2bd3f3b

Browse files
committed
Refactor to remove IndeterminateComponent
1 parent 23b32d3 commit 2bd3f3b

13 files changed

+87
-256
lines changed

packages/react-devtools-shared/src/backend/renderer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export function getInternalReactConstants(version: string): {
225225
HostSingleton: 27, // Same as above
226226
HostText: 6,
227227
IncompleteClassComponent: 17,
228-
IndeterminateComponent: 2,
228+
IndeterminateComponent: 2, // removed in 19.0.0
229229
LazyComponent: 16,
230230
LegacyHiddenComponent: 23,
231231
MemoComponent: 14,

packages/react-dom/src/__tests__/ReactCompositeComponent-test.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,16 @@ describe('ReactCompositeComponent', () => {
223223
const el = document.createElement('div');
224224
const root = ReactDOMClient.createRoot(el);
225225
await expect(async () => {
226-
await expect(async () => {
227-
await act(() => {
228-
root.render(<Child test="test" />);
229-
});
230-
}).rejects.toThrow(
231-
'Objects are not valid as a React child (found: object with keys {render}).',
232-
);
233-
}).toErrorDev(
234-
'Warning: The <Child /> component appears to be a function component that returns a class instance. ' +
235-
'Change Child to a class that extends React.Component instead. ' +
236-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
237-
'`Child.prototype = React.Component.prototype`. ' +
238-
"Don't use an arrow function since it cannot be called with `new` by React.",
226+
await act(() => {
227+
root.render(<Child test="test" />);
228+
});
229+
}).rejects.toThrow(
230+
'Objects are not valid as a React child (found: object with keys {render}).',
239231
);
240232

241233
expect(el.textContent).toBe('');
242234
});
235+
243236
it('should use default values for undefined props', async () => {
244237
class Component extends React.Component {
245238
static defaultProps = {prop: 'testKey'};

packages/react-reconciler/src/ReactFiber.js

+5-16
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import {
4242
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
4343
import {ConcurrentRoot} from './ReactRootTags';
4444
import {
45-
IndeterminateComponent,
4645
ClassComponent,
4746
HostRoot,
4847
HostComponent,
@@ -248,19 +247,10 @@ export function isSimpleFunctionComponent(type: any): boolean {
248247
);
249248
}
250249

251-
export function resolveLazyComponentTag(Component: Function): WorkTag {
252-
if (typeof Component === 'function') {
253-
return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
254-
} else if (Component !== undefined && Component !== null) {
255-
const $$typeof = Component.$$typeof;
256-
if ($$typeof === REACT_FORWARD_REF_TYPE) {
257-
return ForwardRef;
258-
}
259-
if ($$typeof === REACT_MEMO_TYPE) {
260-
return MemoComponent;
261-
}
262-
}
263-
return IndeterminateComponent;
250+
export function isFunctionClassComponent(
251+
type: (...args: Array<any>) => mixed,
252+
): boolean {
253+
return shouldConstruct(type);
264254
}
265255

266256
// This is used to create an alternate fiber to do work on.
@@ -351,7 +341,6 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
351341
workInProgress._debugInfo = current._debugInfo;
352342
workInProgress._debugNeedsRemount = current._debugNeedsRemount;
353343
switch (workInProgress.tag) {
354-
case IndeterminateComponent:
355344
case FunctionComponent:
356345
case SimpleMemoComponent:
357346
workInProgress.type = resolveFunctionForHotReloading(current.type);
@@ -492,7 +481,7 @@ export function createFiberFromTypeAndProps(
492481
mode: TypeOfMode,
493482
lanes: Lanes,
494483
): Fiber {
495-
let fiberTag = IndeterminateComponent;
484+
let fiberTag = FunctionComponent;
496485
// The resolved type is set if we know what the final type will be. I.e. it's not lazy.
497486
let resolvedType = type;
498487
if (typeof type === 'function') {

0 commit comments

Comments
 (0)