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

Remove startTransition and useActionState from react-server condition of react #29753

Conversation

huozhi
Copy link
Contributor

@huozhi huozhi commented Jun 4, 2024

Summary

Remove startTransition and useActionState from react-server condition of react, as they should only stay in client bundle.
This will reduce the server bundle of react itself.

Found this while tracing where the process.emit was called.

How did you test this change?

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 4:17pm

@react-sizebot
Copy link

react-sizebot commented Jun 4, 2024

Comparing: 4082582...85d9da4

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.66 kB 6.66 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.26 kB 497.26 kB = 89.11 kB 89.11 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.08 kB 502.08 kB = 89.80 kB 89.80 kB
facebook-www/ReactDOM-prod.classic.js = 594.75 kB 594.75 kB = 104.76 kB 104.76 kB
facebook-www/ReactDOM-prod.modern.js = 571.14 kB 571.14 kB = 101.18 kB 101.18 kB
oss-stable/react/cjs/react.react-server.development.js = 70.33 kB 67.45 kB = 19.72 kB 18.99 kB
oss-stable-rc/react/cjs/react.react-server.development.js = 70.31 kB 67.42 kB = 19.69 kB 18.96 kB
oss-stable-semver/react/cjs/react.react-server.development.js = 70.31 kB 67.42 kB = 19.69 kB 18.96 kB
oss-stable/react/cjs/react.react-server.production.js = 14.97 kB 13.30 kB = 4.08 kB 3.68 kB
oss-stable-rc/react/cjs/react.react-server.production.js = 14.95 kB 13.28 kB = 4.06 kB 3.66 kB
oss-stable-semver/react/cjs/react.react-server.production.js = 14.95 kB 13.28 kB = 4.06 kB 3.66 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react/cjs/react.react-server.development.js = 70.33 kB 67.45 kB = 19.72 kB 18.99 kB
oss-stable-rc/react/cjs/react.react-server.development.js = 70.31 kB 67.42 kB = 19.69 kB 18.96 kB
oss-stable-semver/react/cjs/react.react-server.development.js = 70.31 kB 67.42 kB = 19.69 kB 18.96 kB
oss-stable/react/cjs/react.react-server.production.js = 14.97 kB 13.30 kB = 4.08 kB 3.68 kB
oss-stable-rc/react/cjs/react.react-server.production.js = 14.95 kB 13.28 kB = 4.06 kB 3.66 kB
oss-stable-semver/react/cjs/react.react-server.production.js = 14.95 kB 13.28 kB = 4.06 kB 3.66 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against 85d9da4

@acdlite
Copy link
Collaborator

acdlite commented Jun 4, 2024

I believe this is intentional since you should be able to reference startTransition in an event handler in a shared component. Similar to how things like useMemo are supported even though there are no re-renders on the server. Never mind, this doesn't make sense

However I don't know why useActionState is in there. That looks like mistake.

@huozhi huozhi marked this pull request as ready for review June 4, 2024 14:15
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.

Can you remove useActionState, too?

@huozhi huozhi changed the title Remove startTransition from react-server condition of react Remove startTransition and useActionState from react-server condition of react Jun 4, 2024
@sebmarkbage
Copy link
Collaborator

@huozhi You need to run yarn prettier.

@sebmarkbage sebmarkbage merged commit 9185b9b into facebook:main Jun 4, 2024
40 checks passed
@huozhi huozhi deleted the huozhi/remove-start-transition-from-react-server-bundle branch June 4, 2024 16:24
github-actions bot pushed a commit that referenced this pull request Jun 4, 2024
… of react (#29753)

<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

Remove `startTransition` and `useActionState` from `react-server`
condition of react, as they should only stay in client bundle.
This will reduce the server bundle of react itself.

Found this while tracing where the `process.emit` was called.

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

## How did you test this change?

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->

DiffTrain build for commit 9185b9b.
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.

5 participants