Skip to content

Commit 23bf0a7

Browse files
committed
Remove the warning and add TODOs
1 parent 3a53a84 commit 23bf0a7

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ function updateForwardRef(
220220
nextProps: any,
221221
renderExpirationTime: ExpirationTime,
222222
) {
223+
// TODO: current can be non-null here even if the component
224+
// hasn't yet mounted. This happens after the first render suspends.
225+
// We'll need to figure out if this is fine or can cause issues.
226+
223227
if (__DEV__) {
224228
if (workInProgress.type !== workInProgress.elementType) {
225229
// Lazy component props can't be validated in createElement
@@ -415,6 +419,10 @@ function updateSimpleMemoComponent(
415419
updateExpirationTime,
416420
renderExpirationTime: ExpirationTime,
417421
): null | Fiber {
422+
// TODO: current can be non-null here even if the component
423+
// hasn't yet mounted. This happens when the inner render suspends.
424+
// We'll need to figure out if this is fine or can cause issues.
425+
418426
if (__DEV__) {
419427
if (workInProgress.type !== workInProgress.elementType) {
420428
// Lazy component props can't be validated in createElement

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,6 @@ function mountWorkInProgressHook(): Hook {
449449

450450
if (__DEV__) {
451451
(hook: any)._debugType = (currentHookNameInDev: any);
452-
if (
453-
currentlyRenderingFiber !== null &&
454-
currentlyRenderingFiber.alternate !== null
455-
) {
456-
warning(
457-
false,
458-
'%s: Rendered more hooks than during the previous render. This is ' +
459-
'not currently supported and may lead to unexpected behavior.',
460-
getComponentName(currentlyRenderingFiber.type),
461-
);
462-
}
463452
}
464453
if (workInProgressHook === null) {
465454
// This is the first hook in the list

packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ describe('ReactHooks', () => {
13691369

13701370
// Regression test for https://github.com/facebook/react/issues/14790
13711371
it('does not fire a false positive warning when suspending memo', async () => {
1372-
const {Suspense, useState, useRef} = React;
1372+
const {Suspense, useState} = React;
13731373

13741374
let wasSuspended = false;
13751375
function trySuspend() {
@@ -1382,7 +1382,7 @@ describe('ReactHooks', () => {
13821382
}
13831383

13841384
function Child() {
1385-
React.useState();
1385+
useState();
13861386
trySuspend();
13871387
return 'hello';
13881388
}
@@ -1400,7 +1400,7 @@ describe('ReactHooks', () => {
14001400

14011401
// Regression test for https://github.com/facebook/react/issues/14790
14021402
it('does not fire a false positive warning when suspending forwardRef', async () => {
1403-
const {Suspense, useState, useRef} = React;
1403+
const {Suspense, useState} = React;
14041404

14051405
let wasSuspended = false;
14061406
function trySuspend() {
@@ -1413,7 +1413,7 @@ describe('ReactHooks', () => {
14131413
}
14141414

14151415
function render(props, ref) {
1416-
React.useState();
1416+
useState();
14171417
trySuspend();
14181418
return 'hello';
14191419
}
@@ -1431,7 +1431,7 @@ describe('ReactHooks', () => {
14311431

14321432
// Regression test for https://github.com/facebook/react/issues/14790
14331433
it('does not fire a false positive warning when suspending memo(forwardRef)', async () => {
1434-
const {Suspense, useState, useRef} = React;
1434+
const {Suspense, useState} = React;
14351435

14361436
let wasSuspended = false;
14371437
function trySuspend() {
@@ -1444,7 +1444,7 @@ describe('ReactHooks', () => {
14441444
}
14451445

14461446
function render(props, ref) {
1447-
React.useState();
1447+
useState();
14481448
trySuspend();
14491449
return 'hello';
14501450
}

0 commit comments

Comments
 (0)