From ff7fb6efda0418752302cfa461ade600e636943b Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 24 Mar 2017 04:48:36 -0700 Subject: [PATCH] Allow overrides of NativeModules Reviewed By: mhorowitz Differential Revision: D4764126 fbshipit-source-id: 036f848f8b3debbb3cc4a34fc99044304615760e --- ReactCommon/cxxreact/JSCNativeModules.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactCommon/cxxreact/JSCNativeModules.cpp b/ReactCommon/cxxreact/JSCNativeModules.cpp index 105873cfd..f55e00497 100644 --- a/ReactCommon/cxxreact/JSCNativeModules.cpp +++ b/ReactCommon/cxxreact/JSCNativeModules.cpp @@ -12,7 +12,7 @@ JSCNativeModules::JSCNativeModules(std::shared_ptr moduleRegistr JSValueRef JSCNativeModules::getModule(JSContextRef context, JSStringRef jsName) { if (!m_moduleRegistry) { - return Value::makeUndefined(context); + return nullptr; } std::string moduleName = String::ref(context, jsName).str(); @@ -24,7 +24,8 @@ JSValueRef JSCNativeModules::getModule(JSContextRef context, JSStringRef jsName) auto module = createModule(moduleName, context); if (!module.hasValue()) { - return Value::makeUndefined(context); + // Allow lookup to continue in the objects own properties, which allows for overrides of NativeModules + return nullptr; } // Protect since we'll be holding on to this value, even though JS may not