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
This commit is contained in:
Rubén Norte
2019-05-17 10:04:49 -07:00
committed by Facebook Github Bot
parent ad4a5d9a3e
commit edb07c1f64
+1 -1
View File
@@ -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.`,