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

[crud] Merge useResourceEffect into useEffect #32205

Merged
merged 1 commit into from
Feb 11, 2025
Merged

[crud] Merge useResourceEffect into useEffect #32205

merged 1 commit into from
Feb 11, 2025

Conversation

poteto
Copy link
Member

@poteto poteto commented Jan 23, 2025

Merges the useResourceEffect API into useEffect while keeping the underlying implementation the same. useResourceEffect will be removed in the next diff.

To fork between behavior we rely on a typeof check for the updater or destroy function in addition to the CRUD feature flag. This does now have to be checked every time (instead of inlined statically like before due to them being different hooks) which will incur some non-zero amount (possibly negligble) of overhead for every effect.

Stack created with Sapling. Best reviewed with ReviewStack.

@react-sizebot
Copy link

react-sizebot commented Jan 23, 2025

Comparing: 0461c0d...078590f

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.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.03% 515.48 kB 515.62 kB +0.04% 92.04 kB 92.07 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.03% 558.52 kB 558.66 kB +0.04% 99.27 kB 99.31 kB
facebook-www/ReactDOM-prod.classic.js +0.08% 636.79 kB 637.33 kB +0.12% 111.92 kB 112.06 kB
facebook-www/ReactDOM-prod.modern.js +0.09% 627.11 kB 627.65 kB +0.12% 110.34 kB 110.47 kB
facebook-react-native/react/cjs/React-prod.js +2.23% 19.53 kB 19.97 kB +1.69% 5.08 kB 5.16 kB
facebook-react-native/react/cjs/React-profiling.js +2.18% 19.97 kB 20.40 kB +1.63% 5.16 kB 5.24 kB
facebook-www/React-prod.modern.js +2.07% 21.04 kB 21.48 kB +1.58% 5.38 kB 5.47 kB
facebook-www/React-prod.classic.js +2.07% 21.04 kB 21.48 kB +1.58% 5.38 kB 5.47 kB
facebook-www/React-profiling.modern.js +2.03% 21.48 kB 21.91 kB +1.56% 5.46 kB 5.55 kB
facebook-www/React-profiling.classic.js +2.03% 21.48 kB 21.91 kB +1.56% 5.46 kB 5.55 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-react-native/react/cjs/React-prod.js +2.23% 19.53 kB 19.97 kB +1.69% 5.08 kB 5.16 kB
facebook-react-native/react/cjs/React-profiling.js +2.18% 19.97 kB 20.40 kB +1.63% 5.16 kB 5.24 kB
facebook-www/React-prod.modern.js +2.07% 21.04 kB 21.48 kB +1.58% 5.38 kB 5.47 kB
facebook-www/React-prod.classic.js +2.07% 21.04 kB 21.48 kB +1.58% 5.38 kB 5.47 kB
facebook-www/React-profiling.modern.js +2.03% 21.48 kB 21.91 kB +1.56% 5.46 kB 5.55 kB
facebook-www/React-profiling.classic.js +2.03% 21.48 kB 21.91 kB +1.56% 5.46 kB 5.55 kB
oss-stable-semver/react/cjs/react.production.js +1.07% 17.00 kB 17.18 kB +1.47% 4.42 kB 4.49 kB
oss-stable/react/cjs/react.production.js +1.07% 17.02 kB 17.21 kB +1.48% 4.45 kB 4.52 kB
oss-experimental/react/cjs/react.production.js +0.99% 18.42 kB 18.60 kB +1.24% 4.77 kB 4.83 kB
facebook-react-native/react/cjs/React-dev.js +0.80% 67.16 kB 67.70 kB +0.60% 14.78 kB 14.87 kB
facebook-www/React-dev.modern.js +0.75% 71.75 kB 72.28 kB +0.67% 15.60 kB 15.71 kB
facebook-www/React-dev.classic.js +0.75% 71.75 kB 72.28 kB +0.68% 15.61 kB 15.71 kB
facebook-www/ReactART-dev.modern.js +0.49% 659.18 kB 662.42 kB +0.12% 104.49 kB 104.61 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js +0.49% 597.03 kB 599.94 kB +0.14% 96.42 kB 96.55 kB
facebook-www/ReactART-dev.classic.js +0.48% 668.68 kB 671.92 kB +0.12% 106.34 kB 106.47 kB
react-native/implementations/ReactFabric-dev.fb.js +0.48% 673.04 kB 676.28 kB +0.11% 109.63 kB 109.75 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js +0.48% 679.60 kB 682.83 kB +0.11% 110.82 kB 110.94 kB
oss-experimental/react/cjs/react.development.js +0.44% 46.19 kB 46.39 kB +0.49% 10.54 kB 10.59 kB
facebook-www/ReactReconciler-dev.modern.js +0.42% 764.67 kB 767.91 kB +0.11% 120.02 kB 120.15 kB
facebook-www/ReactReconciler-dev.classic.js +0.42% 773.88 kB 777.12 kB +0.11% 121.69 kB 121.83 kB
oss-stable-semver/react/cjs/react.development.js +0.36% 56.16 kB 56.37 kB +0.43% 12.50 kB 12.55 kB
oss-stable/react/cjs/react.development.js +0.36% 56.19 kB 56.39 kB +0.43% 12.52 kB 12.58 kB
facebook-react-native/react-dom/cjs/ReactDOMClient-dev.js +0.33% 995.17 kB 998.42 kB +0.08% 167.43 kB 167.56 kB
facebook-react-native/react-dom/cjs/ReactDOMProfiling-dev.js +0.32% 1,011.51 kB 1,014.76 kB +0.08% 170.27 kB 170.40 kB
facebook-www/ReactDOM-dev.modern.js +0.29% 1,111.30 kB 1,114.55 kB +0.09% 185.53 kB 185.70 kB
facebook-www/ReactDOM-dev.classic.js +0.29% 1,120.45 kB 1,123.69 kB +0.09% 187.26 kB 187.42 kB
facebook-www/ReactDOMTesting-dev.modern.js +0.29% 1,128.21 kB 1,131.45 kB +0.08% 189.41 kB 189.57 kB
facebook-www/ReactDOMTesting-dev.classic.js +0.29% 1,137.35 kB 1,140.60 kB +0.09% 191.11 kB 191.27 kB

Generated by 🚫 dangerJS against 80075c5

poteto added a commit that referenced this pull request Feb 11, 2025

Verified

This commit was signed with the committer’s verified signature.
nickzelei Nick Zelei
Small refactor to the `resource` type to narrow it to an arbitrary
object or void/null instead of the top type. This makes the overload on
useEffect simpler since the return type of create is no longer widened
to the top type when we merge their definitions.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32203).
* #32206
* #32205
* #32204
* __->__ #32203
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Small refactor to the `resource` type to narrow it to an arbitrary
object or void/null instead of the top type. This makes the overload on
useEffect simpler since the return type of create is no longer widened
to the top type when we merge their definitions.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32203).
* #32206
* #32205
* #32204
* __->__ #32203

DiffTrain build for [899e3d1](899e3d1)
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Small refactor to the `resource` type to narrow it to an arbitrary
object or void/null instead of the top type. This makes the overload on
useEffect simpler since the return type of create is no longer widened
to the top type when we merge their definitions.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32203).
* #32206
* #32205
* #32204
* __->__ #32203

DiffTrain build for [899e3d1](899e3d1)
poteto added a commit that referenced this pull request Feb 11, 2025
Rename the flag in preparation for the overload.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32204).
* #32206
* #32205
* __->__ #32204
Merges the useResourceEffect API into useEffect while keeping the underlying implementation the same. useResourceEffect will be removed in the next diff.

To fork between behavior we rely on a `typeof` check for the updater or destroy function in addition to the CRUD feature flag. This does now have to be checked every time (instead of inlined statically like before due to them being different hooks) which will incur some non-zero amount (possibly negligble) of overhead for every effect.
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Rename the flag in preparation for the overload.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32204).
* #32206
* #32205
* __->__ #32204

DiffTrain build for [0461c0d](0461c0d)
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Rename the flag in preparation for the overload.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32204).
* #32206
* #32205
* __->__ #32204

DiffTrain build for [0461c0d](0461c0d)
@poteto poteto merged commit 2c5fd26 into main Feb 11, 2025
190 checks passed
@poteto poteto deleted the pr32205 branch February 11, 2025 19:18
poteto added a commit that referenced this pull request Feb 11, 2025
Removes useResourceEffect.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32206).
* __->__ #32206
* #32205
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Removes useResourceEffect.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32206).
* __->__ #32206
* #32205

DiffTrain build for [a69b80d](a69b80d)
github-actions bot pushed a commit that referenced this pull request Feb 11, 2025
Removes useResourceEffect.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32206).
* __->__ #32206
* #32205

DiffTrain build for [a69b80d](a69b80d)
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.

None yet

4 participants