mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add API for getting sourceURL directly from ReactContext
Summary: In bridgeless mode, the CatalystInstance doesn't exist, but we still need to be able to access the sourceURL in SourceCodeModule (which is needed to render the images in LogBox warnings and errors). This diff adds a new API for getting the sourceURL directly from ReactContext, instead of having to call context.getCatalystInstance().getSourceURL(), and updates SourceCodeModule to use it. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D20848700 fbshipit-source-id: 3ecda81a17121178b76bbb3e9b0f27f103c1961a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4cbcee7567
commit
9d56c07bea
@@ -455,4 +455,14 @@ public class ReactContext extends ContextWrapper {
|
||||
}
|
||||
return mCatalystInstance.getJSIModule(moduleType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sourceURL for the JS bundle from the CatalystInstance. This method is needed for
|
||||
* compatibility with bridgeless mode, which has no CatalystInstance.
|
||||
*
|
||||
* @return The JS bundle URL set when the bundle was loaded
|
||||
*/
|
||||
public @Nullable String getSourceURL() {
|
||||
return mCatalystInstance.getSourceURL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SourceCodeModule extends NativeSourceCodeSpec {
|
||||
|
||||
String sourceURL =
|
||||
Assertions.assertNotNull(
|
||||
getReactApplicationContext().getCatalystInstance().getSourceURL(),
|
||||
getReactApplicationContext().getSourceURL(),
|
||||
"No source URL loaded, have you initialised the instance?");
|
||||
|
||||
constants.put("scriptURL", sourceURL);
|
||||
|
||||
Reference in New Issue
Block a user