Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid direct React client API imports in the server graph (#40686)
We have heuristic checks in the SWC transform to make sure you are not using client-only APIs such as `useState` inside the Server Components graph. However inside our server graph compilation we also have to import the framework and renderer itself (not just the component), and some utility files import these client APIs (because they can be shared by the SSR or client code). Hence we have errors like https://github.com/vercel/next.js/actions/runs/3083270196/jobs/4984135491. To manually opt-out these errors, you can do `import React from 'react'` and use these APIs via `React.useState`. cc @feedthejim ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information