[ReactNative] Use JSValueIsUndefined instead of comparing with JSValueMakeUndefined

Summary:
@public

Use JSValueIsUndefined instead of caching an JSValueMakeUndefined to compare with
as suggested in https://github.com/facebook/react-native/pull/1432#commitcomment-11437434

Test Plan: Run the RCTContextExecutor tests
This commit is contained in:
Tadeu Zagallo 2015-05-30 13:21:42 -07:00
parent f8b3c98bc6
commit 1c692e2eb6

View File

@ -66,7 +66,6 @@
{
RCTJavaScriptContext *_context;
NSThread *_javaScriptThread;
JSValueRef _undefined;
}
/**
@ -238,9 +237,6 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
JSContextGroupRelease(group);
}
// Constant value used for comparison
_undefined = JSValueMakeUndefined(ctx);
strongSelf->_context = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
[strongSelf _addNativeHook:RCTNativeLoggingHook withName:"nativeLoggingHook"];
[strongSelf _addNativeHook:RCTNoop withName:"noop"];
@ -312,7 +308,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
JSValueRef requireJSRef = JSObjectGetProperty(contextJSRef, globalObjectJSRef, requireNameJSStringRef, &errorJSRef);
JSStringRelease(requireNameJSStringRef);
if (requireJSRef != NULL && requireJSRef != _undefined && errorJSRef == NULL) {
if (requireJSRef != NULL && !JSValueIsUndefined(contextJSRef, requireJSRef) && errorJSRef == NULL) {
// get module
JSStringRef moduleNameJSStringRef = JSStringCreateWithCFString((__bridge CFStringRef)name);