Fix prepack warning in RN bridge code

Reviewed By: yungsters

Differential Revision: D7903364

fbshipit-source-id: 4ef888f4e7f773f9fbc5183db2470b0f7b368d8a
This commit is contained in:
Riley Dulin 2018-05-08 17:57:51 -07:00 committed by Facebook Github Bot
parent b5a780608e
commit 7e97ed00bc
1 changed files with 12 additions and 1 deletions

View File

@ -40,7 +40,18 @@ const FrameRateLogger = {
'Trying to debug FrameRateLogger without the native module!',
);
}
NativeModules.FrameRateLogger && NativeModules.FrameRateLogger.setGlobalOptions(options);
if (NativeModules.FrameRateLogger) {
// Freeze the object to avoid the prepack warning (PP0017) about leaking
// unfrozen objects.
// Needs to clone the object first to avoid modifying the argument.
const optionsClone = {
debug: !!options.debug,
reportStackTraces: !!options.reportStackTraces,
};
Object.freeze(optionsClone);
Object.seal(optionsClone);
NativeModules.FrameRateLogger.setGlobalOptions(optionsClone);
}
},
/**