From edb07c1f642afcdd70e625f03e0003d3009b9a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 17 May 2019 09:59:01 -0700 Subject: [PATCH] Fallback to empty object when native module constants are not defined Summary: Force `getConstants` in native modules to return an empty object when they're not defined in their native implementations. Reviewed By: fkgozali Differential Revision: D15393585 fbshipit-source-id: cdda9df0d0f0a98ba226340d3cee67fec63e106c --- Libraries/BatchedBridge/NativeModules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/BatchedBridge/NativeModules.js b/Libraries/BatchedBridge/NativeModules.js index a916f37b3ab..df60fc87001 100644 --- a/Libraries/BatchedBridge/NativeModules.js +++ b/Libraries/BatchedBridge/NativeModules.js @@ -64,7 +64,7 @@ function genModule( Object.assign(module, constants); if (module.getConstants == null) { - module.getConstants = () => constants; + module.getConstants = () => constants || Object.freeze({}); } else { console.warn( `Unable to define method 'getConstants()' on NativeModule '${moduleName}'. NativeModule '${moduleName}' already has a constant or method called 'getConstants'. Please remove it.`,