mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Cache constants for MP Search NativeModules
Summary: TurboModules doesn't cache invocations of getConstants(). This diff looks at which NativeModules' getConstants() methods gets repeated called in Marketplace, and caches those invocations in JS. Reviewed By: fkgozali Differential Revision: D21874123 fbshipit-source-id: a44b98b3ac8621f67c9c0f3b7c4003a561d1e15d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4e9c428328
commit
96fdaa541e
@@ -19,4 +19,19 @@ export interface Spec extends TurboModule {
|
||||
|};
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.getEnforcing<Spec>('SourceCode'): Spec);
|
||||
const NativeModule = TurboModuleRegistry.getEnforcing<Spec>('SourceCode');
|
||||
let constants = null;
|
||||
|
||||
const NativeSourceCode = {
|
||||
getConstants(): {|
|
||||
scriptURL: string,
|
||||
|} {
|
||||
if (constants == null) {
|
||||
constants = NativeModule.getConstants();
|
||||
}
|
||||
|
||||
return constants;
|
||||
},
|
||||
};
|
||||
|
||||
export default NativeSourceCode;
|
||||
|
||||
Reference in New Issue
Block a user