Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.