Skip to content

Commit

Permalink
fix: Runtime type
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 15, 2025
1 parent 9406d00 commit 94b823d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/nitrogen/src/views/ViewComponentShadowNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace ${namespace} {
const react::RawValue* rawValue = rawProps.at("${prop.name}", nullptr, nullptr);
if (rawValue == nullptr) { ${prop.type.kind === 'optional' ? 'return nullptr;' : `throw std::runtime_error("${spec.name}: Prop \\"${prop.name}\\" is required and cannot be undefined!");`} }
const auto& [runtime, value] = (std::pair<jsi::Runtime*, const jsi::Value&>)*rawValue;
return JSIConverter<${prop.type.getCode('c++')}>::fromJSI(runtime, value);
return JSIConverter<${prop.type.getCode('c++')}>::fromJSI(*runtime, value);
}())`.trim()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace margelo::nitro::image::views {
const react::RawValue* rawValue = rawProps.at("someProp", nullptr, nullptr);
if (rawValue == nullptr) { throw std::runtime_error("TestView: Prop \"someProp\" is required and cannot be undefined!"); }
const auto& [runtime, value] = (std::pair<jsi::Runtime*, const jsi::Value&>)*rawValue;
return JSIConverter<bool>::fromJSI(runtime, value);
return JSIConverter<bool>::fromJSI(*runtime, value);
}()),
/* someCallback */ someCallback([&](){
const react::RawValue* rawValue = rawProps.at("someCallback", nullptr, nullptr);
if (rawValue == nullptr) { throw std::runtime_error("TestView: Prop \"someCallback\" is required and cannot be undefined!"); }
const auto& [runtime, value] = (std::pair<jsi::Runtime*, const jsi::Value&>)*rawValue;
return JSIConverter<std::function<void(double /* someParam */)>>::fromJSI(runtime, value);
return JSIConverter<std::function<void(double /* someParam */)>>::fromJSI(*runtime, value);
}()) {
// TODO: Instead of eagerly converting each prop, only convert the ones that changed on demand.
}
Expand Down

0 comments on commit 94b823d

Please sign in to comment.