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

chore: relax forbidden react server API errors #27878

Merged
merged 5 commits into from Apr 5, 2024

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Mar 26, 2024

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.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Mar 26, 2024
@EvanBacon EvanBacon changed the title chore: relax forbidden react API errors chore: relax forbidden react server API errors Mar 26, 2024
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Mar 26, 2024
@EvanBacon EvanBacon merged commit 96c7370 into main Apr 5, 2024
11 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/babel/relax-server-restrictions branch April 5, 2024 19:27
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants