Skip to content

Warn when second callback is passed to setState/dispatch in Hooks#14625

Merged
gaearon merged 1 commit intofacebook:masterfrom
gaearon:no-cb
Jan 18, 2019
Merged

Warn when second callback is passed to setState/dispatch in Hooks#14625
gaearon merged 1 commit intofacebook:masterfrom
gaearon:no-cb

Conversation

@gaearon
Copy link
Copy Markdown
Collaborator

@gaearon gaearon commented Jan 18, 2019

It's supported in classes and not in Hooks. People try to pass it and wonder why it doesn't work. Now we warn for that. This also lets us add it (or something else) later as a second argument.


if (__DEV__) {
warning(
arguments.length <= 3,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Could've been === 3 but I figured I don't want to punish users for our bugs.

@sizebot
Copy link
Copy Markdown

sizebot commented Jan 18, 2019

ReactDOM: size: 0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: d17d0b9...faa7bc2

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js 0.0% +0.1% 732.6 KB 732.87 KB 168.96 KB 169.04 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 98.92 KB 98.92 KB 32.21 KB 32.21 KB UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 101.9 KB 101.9 KB 32.84 KB 32.83 KB UMD_PROFILING
react-dom.development.js 0.0% +0.1% 727.66 KB 727.93 KB 167.53 KB 167.62 KB NODE_DEV
react-dom.production.min.js 0.0% -0.0% 98.92 KB 98.92 KB 31.66 KB 31.66 KB NODE_PROD
ReactDOM-dev.js 0.0% +0.1% 749.63 KB 749.96 KB 168.69 KB 168.79 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% -0.0% 311.37 KB 311.37 KB 57.48 KB 57.48 KB FB_WWW_PROD
react-dom-unstable-fire.development.js 0.0% +0.1% 732.95 KB 733.21 KB 169.1 KB 169.19 KB UMD_DEV
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 101.92 KB 101.92 KB 32.84 KB 32.84 KB UMD_PROFILING
react-dom-unstable-fire.development.js 0.0% +0.1% 728.01 KB 728.27 KB 167.67 KB 167.76 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% -0.0% 98.94 KB 98.94 KB 31.67 KB 31.67 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 102.04 KB 102.04 KB 32.3 KB 32.3 KB NODE_PROFILING
ReactFire-dev.js 0.0% +0.1% 748.84 KB 749.17 KB 168.64 KB 168.74 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.29 KB 60.29 KB 15.79 KB 15.79 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 16.96 KB 16.96 KB 6.53 KB 6.53 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.63 KB 3.63 KB 1.44 KB 1.44 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 706 B 705 B UMD_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 667 B 666 B NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 511.45 KB 511.72 KB 112.79 KB 112.88 KB UMD_DEV
react-art.development.js +0.1% +0.1% 442.97 KB 443.24 KB 95.67 KB 95.76 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 55.95 KB 55.95 KB 17.24 KB 17.24 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 451.35 KB 451.68 KB 94.72 KB 94.82 KB FB_WWW_DEV
ReactART-prod.js 0.0% -0.0% 187.27 KB 187.27 KB 32.13 KB 32.13 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.1% 575.84 KB 576.18 KB 125.24 KB 125.34 KB RN_FB_DEV
ReactNativeRenderer-dev.js +0.1% +0.1% 575.76 KB 576.09 KB 125.2 KB 125.3 KB RN_OSS_DEV
ReactNativeRenderer-profiling.js 0.0% -0.0% 233.1 KB 233.1 KB 40.87 KB 40.87 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 566.7 KB 567.03 KB 122.95 KB 123.06 KB RN_FB_DEV
ReactFabric-profiling.js 0.0% -0.0% 241.31 KB 241.31 KB 42.6 KB 42.6 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 566.6 KB 566.94 KB 122.91 KB 123.02 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% -0.0% 220.31 KB 220.31 KB 38.03 KB 38.03 KB RN_OSS_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.1% +0.1% 456.18 KB 456.45 KB 98.44 KB 98.53 KB UMD_DEV
react-test-renderer.development.js +0.1% +0.1% 451.14 KB 451.41 KB 97.21 KB 97.3 KB NODE_DEV
react-test-renderer.production.min.js 0.0% -0.0% 57.02 KB 57.02 KB 17.46 KB 17.46 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.1% 459.74 KB 460.07 KB 96.61 KB 96.71 KB FB_WWW_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.2 KB 11.2 KB 3.49 KB 3.49 KB NODE_PROD

Generated by 🚫 dangerJS

Copy link
Copy Markdown
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

LGTM

@gaearon gaearon merged commit 177fb76 into facebook:master Jan 18, 2019
@gaearon gaearon deleted the no-cb branch January 18, 2019 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants