diff --git a/packages/nitrogen/src/views/ViewComponentShadowNode.ts b/packages/nitrogen/src/views/ViewComponentShadowNode.ts index b418cbf2..0dced8fd 100644 --- a/packages/nitrogen/src/views/ViewComponentShadowNode.ts +++ b/packages/nitrogen/src/views/ViewComponentShadowNode.ts @@ -32,8 +32,18 @@ export function getViewComponentNames( } export function createViewComponentShadowNodeFiles( - spec: HybridObjectSpec + specOriginal: HybridObjectSpec ): SourceFile[] { + // Due to internal Fabric details, props must be alphabetically sorted. + const sortedProps = [...specOriginal.properties].sort((a, b) => { + if (a.name < b.name) return -1 + else if (a.name > b.name) return 1 + else return 0 + }) + const spec: HybridObjectSpec = { + ...specOriginal, + properties: sortedProps, + } if (!spec.isHybridView) { throw new Error( `Cannot create View Component ShadowNode code for ${spec.name} - it's not a HybridView!` diff --git a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp index 2fd0f387..450b28e4 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp +++ b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp @@ -16,28 +16,28 @@ namespace margelo::nitro::image::views { const HybridTestViewProps& sourceProps, const react::RawProps& rawProps): react::ViewProps(context, sourceProps, rawProps, filterObjectKeys), - someProp([&]() -> CachedProp { - const react::RawValue* rawValue = rawProps.at("someProp", nullptr, nullptr); - if (rawValue == nullptr) return {}; - const auto& [runtime, value] = (std::pair)*rawValue; - return CachedProp::fromRawValue(*runtime, value, sourceProps.someProp); - }()), someCallback([&]() -> CachedProp> { const react::RawValue* rawValue = rawProps.at("someCallback", nullptr, nullptr); if (rawValue == nullptr) return {}; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp>::fromRawValue(*runtime, value, sourceProps.someCallback); + }()), + someProp([&]() -> CachedProp { + const react::RawValue* rawValue = rawProps.at("someProp", nullptr, nullptr); + if (rawValue == nullptr) return {}; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp::fromRawValue(*runtime, value, sourceProps.someProp); }()) { } HybridTestViewProps::HybridTestViewProps(const HybridTestViewProps& other): react::ViewProps(), - someProp(other.someProp), - someCallback(other.someCallback) { } + someCallback(other.someCallback), + someProp(other.someProp) { } bool HybridTestViewProps::filterObjectKeys(const std::string& propName) { switch (hashString(propName)) { - case hashString("someProp"): return true; case hashString("someCallback"): return true; + case hashString("someProp"): return true; default: return false; } } diff --git a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp index 5f67bf50..33361f99 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp @@ -41,8 +41,8 @@ namespace margelo::nitro::image::views { const react::RawProps& rawProps); public: - CachedProp someProp; CachedProp> someCallback; + CachedProp someProp; private: static bool filterObjectKeys(const std::string& propName);