// Copyright 2018-present 650 Industries. All rights reserved. #include "FabricComponentsRegistry.h" #include #include #include "ExpoViewComponentDescriptor.h" namespace jni = facebook::jni; namespace react = facebook::react; namespace expo { // static void FabricComponentsRegistry::registerNatives() { registerHybrid({ makeNativeMethod("initHybrid", FabricComponentsRegistry::initHybrid), makeNativeMethod("registerComponentsRegistry", FabricComponentsRegistry::registerComponentsRegistry), }); } // static jni::local_ref FabricComponentsRegistry::initHybrid(jni::alias_ref jThis) { return makeCxxInstance(); } void FabricComponentsRegistry::registerComponentsRegistry( jni::alias_ref> componentNames) { // Inject the component to the CoreComponentsRegistry because we don't want to touch the MainApplicationReactNativeHost auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry(); size_t size = componentNames->size(); for (size_t i = 0; i < size; ++i) { auto flavor = std::make_shared(componentNames->getElement(i)->toStdString()); auto componentName = react::ComponentName{flavor->c_str()}; providerRegistry->add(react::ComponentDescriptorProvider { reinterpret_cast(componentName), componentName, flavor, &facebook::react::concreteComponentDescriptorConstructor }); } } } // namespace expo