Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't warn about unmounted updates if pending passive unmount #18096

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Feb 21, 2020

I recently landed a change to the timing of passive effect cleanup functions during unmount (see #17925). This change defers flushing of passive effects for unmounted components until later (whenever we next flush pending passive effects).

Since this change increases the likelihood of a (not actionable) state update warning for unmounted components, I've suppressed that warning for Fibers that have scheduled passive effect unmounts pending.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 21, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 21, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@bvaughn bvaughn requested review from sebmarkbage, threepointone and acdlite and removed request for sebmarkbage and threepointone February 21, 2020 18:28
Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop using 'assign' for reviews you dork 🤪

return;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd, syntax highlighting seems to be broken for this file
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Yeah for me me too.

@sizebot
Copy link

sizebot commented Feb 21, 2020

Details of bundled changes.

Comparing: 65bbda7...fbd5194

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 59.07 KB 59.07 KB 14.75 KB 14.75 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.02 KB 1.02 KB 620 B 621 B NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.93 KB 3.93 KB 1.45 KB 1.45 KB NODE_DEV
react-dom.development.js -0.0% -0.0% 885.44 KB 885.36 KB 195.3 KB 195.26 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.17 KB 1.17 KB 675 B 676 B NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 19.99 KB 19.99 KB 7.4 KB 7.4 KB UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 119.37 KB 119.37 KB 38.28 KB 38.27 KB UMD_PROFILING
ReactDOMTesting-dev.js -0.0% -0.0% 895.43 KB 895.36 KB 199.68 KB 199.65 KB FB_WWW_DEV
react-dom.development.js -0.0% -0.0% 839.03 KB 838.96 KB 191.72 KB 191.69 KB NODE_DEV
react-dom-server.browser.development.js 0.0% 0.0% 125.94 KB 125.94 KB 33.61 KB 33.61 KB NODE_DEV
react-dom.production.min.js 0.0% -0.0% 115.88 KB 115.88 KB 36.46 KB 36.46 KB NODE_PROD
react-dom-testing.development.js -0.0% -0.0% 885.64 KB 885.57 KB 195.65 KB 195.62 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 19.9 KB 19.9 KB 7.37 KB 7.37 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 119.56 KB 119.56 KB 37.52 KB 37.52 KB NODE_PROFILING
react-dom-testing.production.min.js 0.0% 0.0% 116.93 KB 116.93 KB 37.61 KB 37.61 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 698 B 699 B UMD_PROD
ReactDOM-dev.js 0.0% 0.0% 936.01 KB 936.35 KB 208.1 KB 208.18 KB FB_WWW_DEV
react-dom-testing.development.js -0.0% -0.0% 839.2 KB 839.12 KB 192.11 KB 192.08 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 53.68 KB 53.68 KB 14 KB 14 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 11.2 KB 11.2 KB 4.15 KB 4.15 KB UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 49.51 KB 49.51 KB 13.54 KB 13.54 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.96 KB 10.96 KB 4.08 KB 4.08 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.0% -0.0% 616.82 KB 616.75 KB 130.29 KB 130.26 KB UMD_DEV
react-art.development.js -0.0% -0.0% 518.05 KB 517.98 KB 111.57 KB 111.54 KB NODE_DEV
ReactART-dev.js +0.1% +0.1% 565.17 KB 565.51 KB 118.26 KB 118.34 KB FB_WWW_DEV
ReactART-prod.js 0.0% -0.0% 234.43 KB 234.43 KB 39.76 KB 39.76 KB FB_WWW_PROD

Size changes (stable)

Generated by 🚫 dangerJS against fbd5194

@sizebot
Copy link

sizebot commented Feb 21, 2020

Details of bundled changes.

Comparing: 65bbda7...fbd5194

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 123.61 KB 123.61 KB 38.6 KB 38.6 KB NODE_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.61 KB 3.61 KB 1.37 KB 1.37 KB UMD_DEV
ReactDOM-dev.js 0.0% 0.0% 894.02 KB 894.36 KB 199.58 KB 199.65 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% 0.0% 53.69 KB 53.69 KB 14.01 KB 14.01 KB UMD_DEV
react-dom-testing.profiling.min.js 0.0% 0.0% 121.17 KB 121.17 KB 38.13 KB 38.14 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 138.16 KB 138.16 KB 35.19 KB 35.19 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 11.22 KB 11.22 KB 4.16 KB 4.16 KB UMD_PROD
react-dom-test-utils.development.js 0.0% 0.0% 49.52 KB 49.52 KB 13.55 KB 13.55 KB NODE_DEV
react-dom-server.browser.development.js 0.0% 0.0% 127.45 KB 127.45 KB 33.83 KB 33.83 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.97 KB 10.97 KB 4.09 KB 4.09 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 20.36 KB 20.36 KB 7.45 KB 7.45 KB NODE_PROD
react-dom.development.js -0.0% -0.0% 914.12 KB 914.05 KB 200.3 KB 200.26 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 119.74 KB 119.74 KB 38.22 KB 38.22 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 134.45 KB 134.45 KB 34.27 KB 34.27 KB FB_WWW_DEV
react-dom.development.js -0.0% -0.0% 866.53 KB 866.46 KB 196.63 KB 196.59 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 683 B 684 B NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.21 KB 3.21 KB 1.3 KB 1.3 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.03 KB 1.03 KB 628 B 629 B NODE_PROD
react-dom-testing.development.js -0.0% -0.0% 887.74 KB 887.67 KB 195.83 KB 195.8 KB UMD_DEV
ReactDOMTesting-dev.js -0.0% -0.0% 869.87 KB 869.79 KB 194.66 KB 194.63 KB FB_WWW_DEV
react-dom-testing.profiling.min.js 0.0% 0.0% 120.93 KB 120.93 KB 38.89 KB 38.89 KB UMD_PROFILING
react-dom-testing.development.js -0.0% -0.0% 841.21 KB 841.13 KB 192.29 KB 192.26 KB NODE_DEV
react-dom-server.node.development.js 0.0% 0.0% 128.57 KB 128.57 KB 34.05 KB 34.05 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +0.1% +0.1% 538.57 KB 538.91 KB 112.78 KB 112.86 KB FB_WWW_DEV
react-art.development.js -0.0% -0.0% 636 KB 635.92 KB 133.72 KB 133.68 KB UMD_DEV
react-art.development.js -0.0% -0.0% 536.48 KB 536.41 KB 115.02 KB 114.99 KB NODE_DEV
ReactART-prod.js 0.0% 0.0% 227.25 KB 227.25 KB 38.49 KB 38.49 KB FB_WWW_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against fbd5194

Copy link
Collaborator

@acdlite acdlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Rejecting until I get a chance to review :D

Some version of this is good though

) {
// If there are pending passive effects unmounts for this Fiber,
// we can assume that they would have prevented this update.
if (pendingPassiveHookEffectsUnmount.includes(fiber)) {
Copy link
Collaborator

@acdlite acdlite Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: includes is a new-ish API, so use indexof or something instead so this doesn't break in older browsers.

});
});

it('still warns about state updates for unmounted components with no pending passive unmounts', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for when there's a pending unmount on a different component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@acdlite
Copy link
Collaborator

acdlite commented Feb 21, 2020

I'm personally OK with merging this but I do think we should continue to think about the other types of side effects that might occur in an unmount function but aren't a state update

@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 21, 2020

This change is narrowly scoped to only suppress warnings for things that happen between a committed unmount and flushing of passive effects. It won't block any warnings for anything else- including a setState call made from within the passive effects destroy function.

I recently landed a change to the timing of passive effect cleanup functions during unmount (see facebook#17925). This change defers flushing of passive effects for unmounted components until later (whenever we next flush pending passive effects).

Since this change increases the likelihood of a (not actionable) state update warning for unmounted components, I've suppressed that warning for Fibers that have scheduled passive effect unmounts pending.
@bvaughn bvaughn force-pushed the suppress-unmounted-state-warning-pending-passive-effects branch from f4be010 to fbd5194 Compare February 21, 2020 21:01
@bvaughn bvaughn merged commit 78e8160 into facebook:master Feb 21, 2020
@bvaughn bvaughn deleted the suppress-unmounted-state-warning-pending-passive-effects branch February 21, 2020 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants