[Experiment] Warn if callback ref returns a function#22313
Merged
gaearon merged 1 commit intofacebook:mainfrom Sep 15, 2021
Merged
[Experiment] Warn if callback ref returns a function#22313gaearon merged 1 commit intofacebook:mainfrom
gaearon merged 1 commit intofacebook:mainfrom
Conversation
gaearon
commented
Sep 14, 2021
| export const enableGetInspectorDataForInstanceInProduction = false; | ||
| export const enableSuspenseServerRenderer = true; | ||
| export const enableSelectiveHydration = true; | ||
| export const warnAboutCallbackRefReturningFunction = true; |
Collaborator
Author
There was a problem hiding this comment.
Note: statically true so we do need to mute it in the warning filter.
|
Comparing: 50263d3...6fda8e1 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
725bad1 to
6fda8e1
Compare
gaearon
commented
Sep 14, 2021
| ); | ||
| }); | ||
|
|
||
| // @gate !__DEV__ || warnAboutCallbackRefReturningFunction |
Collaborator
Author
There was a problem hiding this comment.
The test passes in prod even without the flag because the assertions are only about the warning. Hence the condition.
acdlite
approved these changes
Sep 15, 2021
facebook-github-bot
pushed a commit
to facebook/react-native
that referenced
this pull request
Sep 22, 2021
Summary: This sync includes the following changes: - **[f4ac680](facebook/react@f4ac680c7 )**: Fixed broken build script --unsafe-partial flag ([#22324](facebook/react#22324)) //<Brian Vaughn>// - **[67222f0](facebook/react@67222f044 )**: [Experiment] Warn if callback ref returns a function ([#22313](facebook/react#22313)) //<Dan Abramov>// - **[263cfa6](facebook/react@263cfa6ec )**: [Experimental] Add useInsertionEffect ([#21913](facebook/react#21913)) //<Ricky>// - **[806aaa2](facebook/react@806aaa2e2 )**: [useSES shim] Import prefixed native API ([#22310](facebook/react#22310)) //<Andrew Clark>// - **[fd5e01c](facebook/react@fd5e01c2e )**: [useSES/extra] Reuse old selection if possible ([#22307](facebook/react#22307)) //<Andrew Clark>// - **[33226fa](facebook/react@33226fada )**: Check for store mutations before commit ([#22290](facebook/react#22290)) //<Andrew Clark>// - **[86c7ca7](facebook/react@86c7ca70a )**: Fix link ([#22296](facebook/react#22296)) //<Konstantin Popov>// - **[0fd195f](facebook/react@0fd195f29 )**: update error message to include useLayoutEffect or useEffect on bad e… ([#22279](facebook/react#22279)) //<salazarm>// - **[8f96c6b](facebook/react@8f96c6b2a )**: [Bugfix] Prevent infinite update loop caused by a synchronous update in a passive effect ([#22277](facebook/react#22277)) //<Andrew Clark>// - **[4ce89a5](facebook/react@4ce89a58d )**: Test bad useEffect return value with noop-renderer ([#22258](facebook/react#22258)) //<Sebastian Silbermann>// - **[a3fde23](facebook/react@a3fde2358 )**: Detect subscriptions wrapped in startTransition ([#22271](facebook/react#22271)) //<salazarm>// Changelog: [General][Changed] - React Native sync for revisions 95d762e...e8feb11 jest_e2e[run_all_tests] Reviewed By: rickhanlonii Differential Revision: D30966369 fbshipit-source-id: 6c88e591005deb1fd93493628ef4695add49186c
zhengjitf
pushed a commit
to zhengjitf/react
that referenced
this pull request
Apr 15, 2022
jackpope
added a commit
that referenced
this pull request
Apr 22, 2024
Resources - RFC: reactjs/rfcs#205 - Warning implemented in #22313 - Warning enabled in #23145 - Feature added in #25686 We have warned to prevent the old behavior since 18.0.0. The new feature has been on in canary for a while but still triggering the warning. This PR cleans up the warning for 19
github-actions bot
pushed a commit
that referenced
this pull request
Apr 22, 2024
Resources - RFC: reactjs/rfcs#205 - Warning implemented in #22313 - Warning enabled in #23145 - Feature added in #25686 We have warned to prevent the old behavior since 18.0.0. The new feature has been on in canary for a while but still triggering the warning. This PR cleans up the warning for 19 DiffTrain build for commit db913d8.
github-actions bot
pushed a commit
that referenced
this pull request
Apr 22, 2024
Resources - RFC: reactjs/rfcs#205 - Warning implemented in #22313 - Warning enabled in #23145 - Feature added in #25686 We have warned to prevent the old behavior since 18.0.0. The new feature has been on in canary for a while but still triggering the warning. This PR cleans up the warning for 19 DiffTrain build for [db913d8](db913d8)
Akshato07
pushed a commit
to Akshato07/-Luffy
that referenced
this pull request
Feb 20, 2025
Resources - RFC: reactjs/rfcs#205 - Warning implemented in facebook/react#22313 - Warning enabled in facebook/react#23145 - Feature added in facebook/react#25686 We have warned to prevent the old behavior since 18.0.0. The new feature has been on in canary for a while but still triggering the warning. This PR cleans up the warning for 19 DiffTrain build for commit facebook/react@db913d8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Research for reactjs/rfcs#205.
The warning is turned off by default in all builds except FB. During next FB sync, we'll mute the warning but see how much it fires. This will tell us how common returning functions is. If it's not common, we could plausibly warn for this in 17 and forbid returning functions (or even add the new behavior) in 18. This way, we reserve the ability to introduce the new behavior in the future.