Skip to content

Commit

Permalink
Don't register classes only found at runtime
Browse files Browse the repository at this point in the history
Summary:
This caused issues for me when I tried to provide a native module on init that was also KVO'd (and dynamically subclassed)

On closer inspection, it also seems highly inconsistent to register these classes in DEBUG mode but have them fail silently in production. Reducing the difference between debug and release seems like a safer option.

public

Reviewed By: nicklockwood

Differential Revision: D2819838

fb-gh-sync-id: 79ab72b1152c89eae38c965ff7724aba59a00949
  • Loading branch information
javache authored and facebook-github-bot-5 committed Jan 19, 2016
1 parent 1f501a9 commit c8355d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void RCTRegisterModule(Class moduleClass)

// Register module
[RCTModuleClasses addObject:moduleClass];

objc_setAssociatedObject(moduleClass, &RCTBridgeModuleClassIsRegistered,
@NO, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

/**
Expand Down Expand Up @@ -118,10 +121,6 @@ + (void)initialize
if (![RCTModuleClasses containsObject:cls]) {
RCTLogWarn(@"Class %@ was not exported. Did you forget to use "
"RCT_EXPORT_MODULE()?", cls);

RCTRegisterModule(cls);
objc_setAssociatedObject(cls, &RCTBridgeModuleClassIsRegistered,
@NO, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
break;
}
Expand Down

0 comments on commit c8355d3

Please sign in to comment.