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

Enable warning for defaultProps on function components for everyone #25699

Merged
merged 5 commits into from
Nov 17, 2022

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Nov 16, 2022

This also fixes a gap where were weren't warning on memo components.

Part of reactjs/rfcs#107: Deprecate defaultProps on function components

@sizebot
Copy link

sizebot commented Nov 16, 2022

Comparing: 6fb8133...eff7b63

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 153.62 kB 153.62 kB = 48.83 kB 48.83 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 155.55 kB 155.55 kB = 49.47 kB 49.47 kB
facebook-www/ReactDOM-prod.classic.js = 530.40 kB 530.40 kB = 94.14 kB 94.14 kB
facebook-www/ReactDOM-prod.modern.js = 515.66 kB 515.66 kB = 91.95 kB 91.95 kB
facebook-www/ReactDOMForked-prod.classic.js = 530.40 kB 530.40 kB = 94.14 kB 94.14 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server/cjs/react-server.development.js +0.36% 144.95 kB 145.48 kB +0.26% 36.12 kB 36.21 kB
oss-stable/react-server/cjs/react-server.development.js +0.36% 144.95 kB 145.48 kB +0.26% 36.12 kB 36.21 kB
oss-experimental/react-server/cjs/react-server.development.js +0.36% 145.57 kB 146.10 kB +0.23% 36.31 kB 36.40 kB

Generated by 🚫 dangerJS against eff7b63

@sebmarkbage
Copy link
Collaborator Author

There's a case, we maybe don't need to warn about. Most defaultProps are deprecated, except on classes. Later we'll move the resolution of defaultProps on classes to deeper in the reconciliation than in createElement. This means that you can read element.props earlier and it would have the resolved value today which would change. Given that reading element.props is so rare and defaultProps are deprecated on anything else anyway, it's ok to do that without a warning first.

@sebmarkbage sebmarkbage force-pushed the fndefaultprops branch 4 times, most recently from 5e60c08 to 0d2bac7 Compare November 17, 2022 01:55
Copy link
Collaborator

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Are we not concerned with disabling these feature flags for certain forks in the future? Wouldn't that cause failing tests since they don't conditionally assert on warnings depending on the feature flag values?

If we are, I can follow-up with making sure the assertions check the feature flag values first.

Comment on lines -77 to +89
it('should not warn when owner and self are the same for string refs', () => {
ReactFeatureFlags.warnAboutStringRefs = false;

it('should warn when owner and self are the same for string refs', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I can tell the added warning is not because of owner and self are the same but simply because string refs are used.

It should still "not warn if owner and self are the same for string refs", right?

I think the test description is fine to keep while also not doing the ReactFeatureFlags.warnAboutStringRefs = false;.

toErrorDev should fail the test if we would suddenly add a warning "when owner and self are the same for string refs" because that would be a different warning than the one we're expecting now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The important thing is that it warns since we're about to change behavior. Doesn't really matter all that much for what reason it warns.

@sebmarkbage
Copy link
Collaborator Author

Not too worried about disabling these since they're going into the next stable and for Meta they're silenced secondarily in a different layer anyway. So I figured we'd just remove the flags as we do a pass over all the ones that we want always on.

@sebmarkbage sebmarkbage merged commit 7b17f7b into facebook:main Nov 17, 2022
mofeiZ pushed a commit to mofeiZ/react that referenced this pull request Nov 17, 2022
…acebook#25699)

This also fixes a gap where were weren't warning on memo components.
rickhanlonii pushed a commit that referenced this pull request Dec 3, 2022
…25699)

This also fixes a gap where were weren't warning on memo components.
@lcswillems
Copy link

I imagine that if defaultProps support is going to be dropped in the next React major release, it is to enable new features. Is there any discussion about this somewhere?

@eps1lon
Copy link
Collaborator

eps1lon commented Dec 12, 2022

I imagine that if defaultProps support is going to be dropped in the next React major release, it is to enable new features. Is there any discussion about this somewhere?

@icswillems See reactjs/rfcs#107

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jan 30, 2023
Summary:
Three problems popped up during the sync:
- facebook/react@07f46ecf2 breaks breaks tests
- facebook/react@6fb8133ed breaks fbsource tests. I added a workaround and created a test for the team that owns the test.
- https://fb.workplace.com/groups/flowlang/permalink/1198137807458547/ enables local type interference in fbsource but not in github React repo and some code breaks. Addressed in facebook/react#26064

This sync includes the following changes:
- **[17f6912a4](facebook/react@17f6912a4 )**: Add flow types to ReactFiberHooks ([#25752](facebook/react#25752)) //<Samuel Susla>//
- **[f101c2d0d](facebook/react@f101c2d0d )**: Remove Reconciler fork (2/2) ([#25775](facebook/react#25775)) //<Jan Kassens>//
- **[420f0b7fa](facebook/react@420f0b7fa )**: Remove Reconciler fork (1/2) ([#25774](facebook/react#25774)) //<Jan Kassens>//
- **[3ba7add60](facebook/react@3ba7add60 )**: Allow async blocks in `to(Error|Warn)Dev` ([#25338](facebook/react#25338)) //<Sebastian Silbermann>//
- **[fa11bd6ec](facebook/react@fa11bd6ec )**: [ServerRenderer] Add option to send instructions as data attributes ([#25437](facebook/react#25437)) //<mofeiZ>//
- **[e98225485](facebook/react@e98225485 )**: Add ref cleanup function ([#25686](facebook/react#25686)) //<Samuel Susla>//
- **[15557fa67](facebook/react@15557fa67 )**: [Fix] properly track `useId` use in StrictMode in development ([#25713](facebook/react#25713)) //<Josh Story>//
- **[8a23def32](facebook/react@8a23def32 )**: Resubmit Add HydrationSyncLane ([#25711](facebook/react#25711)) //<Tianyu Yao>//
- **[2655c9354](facebook/react@2655c9354 )**: Fizz Browser: fix precomputed chunk being cleared on Node 18 ([#25645](facebook/react#25645)) //<Jimmy Lai>//
- **[c08d8b804](facebook/react@c08d8b804 )**: Revert "Add SyncHydrationLane" ([#25708](facebook/react#25708)) //<Tianyu Yao>//
- **[56ffca8b9](facebook/react@56ffca8b9 )**: Add Bun streaming server renderer ([#25597](facebook/react#25597)) //<Colin McDonnell>//
- **[f31005d6a](facebook/react@f31005d6a )**: Add SyncHydrationLane ([#25698](facebook/react#25698)) //<Tianyu Yao>//
- **[f284d9faf](facebook/react@f284d9faf )**: Track ThenableState alongside other hooks //<Andrew Clark>//
- **[6b4c0314e](facebook/react@6b4c0314e )**: Check thenable instead of thenableState //<Andrew Clark>//
- **[33e3d2878](facebook/react@33e3d2878 )**: Reuse hooks when replaying a suspended component //<Andrew Clark>//
- **[4387d752d](facebook/react@4387d752d )**: Allow more hooks to be added when replaying mount //<Andrew Clark>//
- **[5eb78d0a0](facebook/react@5eb78d0a0 )**: Pass ThenableState to replaySuspendedUnitOfWork //<Andrew Clark>//
- **[4a2d86bdd](facebook/react@4a2d86bdd )**: Don't reset work loop until stack is unwound //<Andrew Clark>//
- **[9dfbd9fa9](facebook/react@9dfbd9fa9 )**: use: Don't suspend if there are pending updates //<Andrew Clark>//
- **[44c4e6f4d](facebook/react@44c4e6f4d )**: Force unwind work loop during selective hydration ([#25695](facebook/react#25695)) //<Andrew Clark>//
- **[7b17f7bbf](facebook/react@7b17f7bbf )**: Enable warning for defaultProps on function components for everyone ([#25699](facebook/react#25699)) //<Sebastian Markbåge>//
- **[6fb8133ed](facebook/react@6fb8133ed )**: Turn on string ref deprecation warning for everybody (not codemoddable) ([#25383](facebook/react#25383)) //<Sebastian Silbermann>//
- **[07f46ecf2](facebook/react@07f46ecf2 )**: Turn on key spread warning in jsx-runtime for everyone ([#25697](facebook/react#25697)) //<Sebastian Markbåge>//
- **[d65b88d03](facebook/react@d65b88d03 )**: Eagerly initialize an mutable object for instance.refs ([#25696](facebook/react#25696)) //<Sebastian Markbåge>//
- **[c343f8025](facebook/react@c343f8025 )**: [react-float] feature detect getRootNode ([#25689](facebook/react#25689)) //<Jan Kassens>//
- **[e1dd0a2f5](facebook/react@e1dd0a2f5 )**: Remove recoverable error when a sync update flows into a dehydrated boundary ([#25692](facebook/react#25692)) //<Sebastian Markbåge>//
- **[c54e3541b](facebook/react@c54e3541b )**: [DevTools] bug fix for Hydrating fibers ([#25663](facebook/react#25663)) //<Mengdi Chen>//

Changelog:
[General][Changed] - React Native sync for revisions d1e35c7...17f6912

jest_e2e[run_all_tests]

Reviewed By: makovkastar

Differential Revision: D42804802

fbshipit-source-id: 6a9f00724cc73378025bbd04edb2d17760a87280
CrispyBaguette pushed a commit to CrispyBaguette/wasm-palette-converter that referenced this pull request Nov 8, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [react](https://reactjs.org/) ([source](https://github.com/facebook/react/tree/HEAD/packages/react)) | dependencies | minor | [`18.1.0` -> `18.3.1`](https://renovatebot.com/diffs/npm/react/18.1.0/18.3.1) |
| [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react)) | dependencies | minor | [`18.0.9` -> `18.3.12`](https://renovatebot.com/diffs/npm/@types%2freact/18.0.9/18.3.12) |

---

### Release Notes

<details>
<summary>facebook/react (react)</summary>

### [`v18.3.1`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1831-April-26-2024)

[Compare Source](facebook/react@v18.3.0...v18.3.1)

-   Export `act` from `react` [f1338f](facebook/react@f1338f8)

### [`v18.3.0`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1830-April-25-2024)

[Compare Source](facebook/react@v18.2.0...v18.3.0)

This release is identical to 18.2 but adds warnings for deprecated APIs and other changes that are needed for React 19.

Read the [React 19 Upgrade Guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide) for more info.

##### React

-   Allow writing to `this.refs` to support string ref codemod [909071](facebook/react@9090712)
-   Warn for deprecated `findDOMNode` outside StrictMode [c3b283](facebook/react@c3b2839)
-   Warn for deprecated `test-utils` methods [d4ea75](facebook/react@d4ea75d)
-   Warn for deprecated Legacy Context outside StrictMode [415ee0](facebook/react@415ee0e)
-   Warn for deprecated string refs outside StrictMode [#&#8203;25383](facebook/react#25383)
-   Warn for deprecated `defaultProps` for function components [#&#8203;25699](facebook/react#25699)
-   Warn when spreading `key` [#&#8203;25697](facebook/react#25697)
-   Warn when using `act` from `test-utils` [d4ea75](facebook/react@d4ea75d)

##### React DOM

-   Warn for deprecated `unmountComponentAtNode` [8a015b](facebook/react@8a015b6)
-   Warn for deprecated `renderToStaticNodeStream` [#&#8203;28874](facebook/react#28874)

### [`v18.2.0`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1820-June-14-2022)

[Compare Source](facebook/react@v18.1.0...v18.2.0)

##### React DOM

-   Provide a component stack as a second argument to `onRecoverableError`. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24591](facebook/react#24591))
-   Fix hydrating into `document` causing a blank page on mismatch. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24523](facebook/react#24523))
-   Fix false positive hydration errors with Suspense. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24480](facebook/react#24480) and  [@&#8203;acdlite](https://github.com/acdlite) in [#&#8203;24532](facebook/react#24532))
-   Fix ignored `setState` in Safari when adding an iframe. ([@&#8203;gaearon](https://github.com/gaearon) in [#&#8203;24459](facebook/react#24459))

##### React DOM Server

-   Pass information about server errors to the client. ([@&#8203;salazarm](https://github.com/salazarm) and [@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24551](facebook/react#24551) and [#&#8203;24591](facebook/react#24591))
-   Allow to provide a reason when aborting the HTML stream. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24680](facebook/react#24680))
-   Eliminate extraneous text separators in the HTML where possible. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24630](facebook/react#24630))
-   Disallow complex children inside `<title>` elements to match the browser constraints. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24679](facebook/react#24679))
-   Fix buffering in some worker environments by explicitly setting `highWaterMark` to `0`. ([@&#8203;jplhomer](https://github.com/jplhomer) in [#&#8203;24641](facebook/react#24641))

##### Server Components (Experimental)

-   Add support for `useId()` inside Server Components. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24172](facebook/react#24172))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNSIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi41IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/49
Co-authored-by: Renovate <renovate@bruyant.xyz>
Co-committed-by: Renovate <renovate@bruyant.xyz>
CrispyBaguette pushed a commit to CrispyBaguette/wasm-palette-converter that referenced this pull request Nov 9, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [react-dom](https://reactjs.org/) ([source](https://github.com/facebook/react/tree/HEAD/packages/react-dom)) | dependencies | minor | [`18.1.0` -> `18.3.1`](https://renovatebot.com/diffs/npm/react-dom/18.1.0/18.3.1) |
| [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom)) | devDependencies | minor | [`18.0.3` -> `18.3.1`](https://renovatebot.com/diffs/npm/@types%2freact-dom/18.0.3/18.3.1) |

---

### Release Notes

<details>
<summary>facebook/react (react-dom)</summary>

### [`v18.3.1`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1831-April-26-2024)

[Compare Source](facebook/react@v18.3.0...v18.3.1)

-   Export `act` from `react` [f1338f](facebook/react@f1338f8)

### [`v18.3.0`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1830-April-25-2024)

[Compare Source](facebook/react@v18.2.0...v18.3.0)

This release is identical to 18.2 but adds warnings for deprecated APIs and other changes that are needed for React 19.

Read the [React 19 Upgrade Guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide) for more info.

##### React

-   Allow writing to `this.refs` to support string ref codemod [909071](facebook/react@9090712)
-   Warn for deprecated `findDOMNode` outside StrictMode [c3b283](facebook/react@c3b2839)
-   Warn for deprecated `test-utils` methods [d4ea75](facebook/react@d4ea75d)
-   Warn for deprecated Legacy Context outside StrictMode [415ee0](facebook/react@415ee0e)
-   Warn for deprecated string refs outside StrictMode [#&#8203;25383](facebook/react#25383)
-   Warn for deprecated `defaultProps` for function components [#&#8203;25699](facebook/react#25699)
-   Warn when spreading `key` [#&#8203;25697](facebook/react#25697)
-   Warn when using `act` from `test-utils` [d4ea75](facebook/react@d4ea75d)

##### React DOM

-   Warn for deprecated `unmountComponentAtNode` [8a015b](facebook/react@8a015b6)
-   Warn for deprecated `renderToStaticNodeStream` [#&#8203;28874](facebook/react#28874)

### [`v18.2.0`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1820-June-14-2022)

[Compare Source](facebook/react@v18.1.0...v18.2.0)

##### React DOM

-   Provide a component stack as a second argument to `onRecoverableError`. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24591](facebook/react#24591))
-   Fix hydrating into `document` causing a blank page on mismatch. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24523](facebook/react#24523))
-   Fix false positive hydration errors with Suspense. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24480](facebook/react#24480) and  [@&#8203;acdlite](https://github.com/acdlite) in [#&#8203;24532](facebook/react#24532))
-   Fix ignored `setState` in Safari when adding an iframe. ([@&#8203;gaearon](https://github.com/gaearon) in [#&#8203;24459](facebook/react#24459))

##### React DOM Server

-   Pass information about server errors to the client. ([@&#8203;salazarm](https://github.com/salazarm) and [@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24551](facebook/react#24551) and [#&#8203;24591](facebook/react#24591))
-   Allow to provide a reason when aborting the HTML stream. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24680](facebook/react#24680))
-   Eliminate extraneous text separators in the HTML where possible. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24630](facebook/react#24630))
-   Disallow complex children inside `<title>` elements to match the browser constraints. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24679](facebook/react#24679))
-   Fix buffering in some worker environments by explicitly setting `highWaterMark` to `0`. ([@&#8203;jplhomer](https://github.com/jplhomer) in [#&#8203;24641](facebook/react#24641))

##### Server Components (Experimental)

-   Add support for `useId()` inside Server Components. ([@&#8203;gnoff](https://github.com/gnoff) in [#&#8203;24172](facebook/react#24172))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNyIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi43IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/50
Co-authored-by: Renovate <renovate@bruyant.xyz>
Co-committed-by: Renovate <renovate@bruyant.xyz>
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.

6 participants