diff --git a/ReactCommon/fabric/uimanager/ComponentDescriptorProviderRegistry.cpp b/ReactCommon/fabric/uimanager/ComponentDescriptorProviderRegistry.cpp index 5a9a4c4e2f8..ec1269e7ea7 100644 --- a/ReactCommon/fabric/uimanager/ComponentDescriptorProviderRegistry.cpp +++ b/ReactCommon/fabric/uimanager/ComponentDescriptorProviderRegistry.cpp @@ -13,6 +13,19 @@ namespace react { void ComponentDescriptorProviderRegistry::add( ComponentDescriptorProvider provider) const { std::unique_lock lock(mutex_); + + assert( + componentDescriptorProviders_.find(provider.handle) == + componentDescriptorProviders_.end() && + "Attempt to register an already registered ComponentDescriptorProvider."); + + if (componentDescriptorProviders_.find(provider.handle) != + componentDescriptorProviders_.end()) { + // Re-registering a provider makes no sense because it's copyable: already + // registered one is as good as any new can be. + return; + } + componentDescriptorProviders_.insert({provider.handle, provider}); for (auto const &weakRegistry : componentDescriptorRegistries_) {