mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook Github Bot
parent
ad4a5d9a3e
commit
edb07c1f64
@@ -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.`,
|
||||
|
||||
Reference in New Issue
Block a user