Skip to content

Commit 7aed21c

Browse files
committed
fixup! Use emplace instead of indexing into _nodeAddons
1 parent 4ed4f1d commit 7aed21c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ CxxNodeApiHostModule::requireNodeAddon(jsi::Runtime &rt,
1919
if (1 == count && args[0].isString()) {
2020
return thisModule.requireNodeAddon(rt, args[0].asString(rt));
2121
}
22+
// TODO: Throw a meaningful error
2223
return jsi::Value::undefined();
2324
}
2425

2526
jsi::Value CxxNodeApiHostModule::requireNodeAddon(jsi::Runtime &rt,
2627
const jsi::String path) {
2728
const std::string pathStr = path.utf8(rt);
2829

29-
auto [it, inserted] = nodeAddons_.emplace(pathStr);
30+
auto [it, inserted] = nodeAddons_.emplace(pathStr, NodeAddon());
3031
NodeAddon &addon = it->second;
31-
32+
3233
// Check if this module has been loaded already, if not then load it...
3334
if (inserted) {
3435
if (!loadNodeAddon(addon, pathStr)) {

packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class JSI_EXPORT CxxNodeApiHostModule : public facebook::react::TurboModule {
3535
bool initializeNodeModule(facebook::jsi::Runtime &rt, NodeAddon &addon);
3636
};
3737

38-
} // namespace callstack::nodeapihost
38+
} // namespace callstack::nodeapihost

0 commit comments

Comments
 (0)