Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: relax forbidden react server API errors (#27878)
# Why In RSC, components can be shared between server and client, the client components may contain react hooks which will run on the client but shouldn't run on the server. This PR reduces the errors to only throw when APIs are used and not when they're simply imported. The import errors still run when importing `Component` or `PureComponent`. To fully support shared components, we'll need a follow up PR to "optimize" server components. This should collapse unused hooks so that they don't run, and therefore don't trigger the static error pass. This optimization pass is a bit tricky since we have old babel passes that obfuscate the expected syntax, ref facebook/react-native#43662 # Test Plan - Updated the tests with the expected syntax. --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
104 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 24 additions & 2 deletions
26
packages/babel-preset-expo/build/restricted-react-api-plugin.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...es/babel-preset-expo/src/__tests__/__snapshots__/restricted-react-api-plugin.test.ts.snap
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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