From 7e97ed00bc5c7cd6a5b8bbc711ddf0e0730ccb8a Mon Sep 17 00:00:00 2001 From: Riley Dulin Date: Tue, 8 May 2018 17:57:51 -0700 Subject: [PATCH] Fix prepack warning in RN bridge code Reviewed By: yungsters Differential Revision: D7903364 fbshipit-source-id: 4ef888f4e7f773f9fbc5183db2470b0f7b368d8a --- Libraries/Interaction/FrameRateLogger.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Libraries/Interaction/FrameRateLogger.js b/Libraries/Interaction/FrameRateLogger.js index 252fc465a..1653b8591 100644 --- a/Libraries/Interaction/FrameRateLogger.js +++ b/Libraries/Interaction/FrameRateLogger.js @@ -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); + } }, /**