Skip to content

Commit f73cebe

Browse files
committed
fix: Remove unused args parameter in createHybridObject(..)
1 parent 5646db3 commit f73cebe

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

packages/react-native-nitro-modules/cpp/turbomodule/NativeNitroModules.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,16 @@ jsi::Value NativeNitroModules::get(jsi::Runtime& runtime, const jsi::PropNameID&
3434
}
3535
if (name == "createHybridObject") {
3636
return jsi::Function::createFromHostFunction(
37-
runtime, jsi::PropNameID::forUtf8(runtime, "createHybridObject"), 2,
37+
runtime, jsi::PropNameID::forUtf8(runtime, "createHybridObject"), 1,
3838
[this](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value {
3939
#ifdef NITRO_DEBUG
40-
if (count != 1 && count != 2) [[unlikely]] {
41-
throw jsi::JSError(runtime, "NitroModules.createHybridObject(..) expects 1 or 2 arguments, but " + std::to_string(count) +
40+
if (count != 1) [[unlikely]] {
41+
throw jsi::JSError(runtime, "NitroModules.createHybridObject(..) expects 1 argument, but " + std::to_string(count) +
4242
" were supplied!");
4343
}
4444
#endif
4545
jsi::String objectName = args[0].asString(runtime);
46-
std::optional<jsi::Object> optionalArgs = std::nullopt;
47-
if (count > 1) {
48-
optionalArgs = args[1].asObject(runtime);
49-
}
50-
51-
return createHybridObject(runtime, objectName, optionalArgs);
46+
return createHybridObject(runtime, objectName);
5247
});
5348
}
5449
if (name == "hasHybridObject") {
@@ -129,11 +124,9 @@ void NativeNitroModules::install(jsi::Runtime& runtime) {
129124
Dispatcher::installRuntimeGlobalDispatcher(runtime, dispatcher);
130125
}
131126

132-
jsi::Value NativeNitroModules::createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName,
133-
const std::optional<jsi::Object>&) {
127+
jsi::Value NativeNitroModules::createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName) {
134128
auto name = hybridObjectName.utf8(runtime);
135-
// TODO: Pass args? Do we need that?
136-
auto hybridObject = HybridObjectRegistry::createHybridObject(name.c_str());
129+
auto hybridObject = HybridObjectRegistry::createHybridObject(name);
137130
return hybridObject->toObject(runtime);
138131
}
139132

packages/react-native-nitro-modules/cpp/turbomodule/NativeNitroModules.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NativeNitroModules : public TurboModule {
2525
// Setup
2626
void install(jsi::Runtime& runtime);
2727
// Hybrid Objects stuff
28-
jsi::Value createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName, const std::optional<jsi::Object>& args);
28+
jsi::Value createHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName);
2929
jsi::Value hasHybridObject(jsi::Runtime& runtime, const jsi::String& hybridObjectName);
3030
jsi::Value getAllHybridObjectNames(jsi::Runtime& runtime);
3131

packages/react-native-nitro-modules/src/NitroModulesTurboModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface NativeNitroSpec extends TurboModule {
1010
// Set up
1111
install(): void
1212
// Hybrid Objects stuff
13-
createHybridObject(name: string, args?: UnsafeObject): UnsafeObject
13+
createHybridObject(name: string): UnsafeObject
1414
hasHybridObject(name: string): boolean
1515
getAllHybridObjectNames(): string[]
1616
// JSI Helpers

0 commit comments

Comments
 (0)