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

Kmagiera/rn74 inspector #340

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Kmagiera/rn74 inspector #340

merged 2 commits into from
Jun 3, 2024

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Jun 3, 2024

This PR implements a workaround for inspector issue on React Native 0.74 and Expo SDK 51.

On that versions, the inspector broke because of this commit facebook/react@37d901e2b8 in react core that removed debug metadata from being passed down from createElement call into react fiber node objects. Despite the problem being addressed by using runtime based retireval approach in facebook/react@61bd00498 we couldn't really use that as it doesn't provide the same level of detail about the components. Specifically, metadata is missing for components w/o props (which is frequent when used react-navigation or expo-router in React Native), and the debug info would always point to component definition line rather than the line where component is rendered. This turned out to be a lot less practical.

There is a new approach implemented in facebook/react@151cce37401 but not yet included in RN while also marked as experimental, so it isn't certain if it has effects or can be used in later versions. Please checkout inline comment in babel_transformer.js file for more context.

The fix this PR implements is to override renderer code that react native pulls in. The renderer is build off of a certain version of react-js and then commited into RN source code. Note that renderer code is not kept in sync with react version used by react native. For example, the mentioned commit that removes source metadata is not a part of react release yet, while react-native depends on react 18.2. What we ended up doing here, is that we pulled in the exact version of react, the renderer is coming from in RN 74 (this is the version: facebook/react@03d6f7cf0), then build renderers (separate files for new and old arch) with the mentioned commit reverted. Then, we use babel_transformer to replace the renderer by replacing source with the patched renderer versions that we are adding to the repo.

This has been tested with RN 74 and Expo 51 projects.

Copy link

vercel bot commented Jun 3, 2024

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

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2024 11:24am

@kmagiera kmagiera merged commit 594ebf9 into main Jun 3, 2024
2 checks passed
@kmagiera kmagiera deleted the kmagiera/rn74-inspector branch June 3, 2024 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant