Skip to content

Commit

Permalink
[ReactNative] Use JSValueIsUndefined instead of comparing with JSValu…
Browse files Browse the repository at this point in the history
…eMakeUndefined

Summary:
@public

Use JSValueIsUndefined instead of caching an JSValueMakeUndefined to compare with
as suggested in facebook#1432 (comment)

Test Plan: Run the RCTContextExecutor tests
  • Loading branch information
tadeuzagallo committed May 30, 2015
1 parent f8b3c98 commit 1c692e2
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions React/Executors/RCTContextExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ @implementation RCTContextExecutor
{
RCTJavaScriptContext *_context;
NSThread *_javaScriptThread;
JSValueRef _undefined;
}

/**
Expand Down Expand Up @@ -238,9 +237,6 @@ - (instancetype)initWithJavaScriptThread:(NSThread *)javaScriptThread
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"];
Expand Down Expand Up @@ -312,7 +308,7 @@ - (void)executeJSCall:(NSString *)name
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);
Expand Down

0 comments on commit 1c692e2

Please sign in to comment.