mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7f22db8ea0
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37522 This diff adds cross-platform Cxx binding helper and iOS specific implementation of `__nativeComponentRegistry__getNativeViewConfig` to JS runtime. This function provides native view config for a native component in bridgeless mode. Changelog: [Internal] - Introduce `__nativeComponentRegistry__getNativeViewConfig` in iOS. Reviewed By: javache Differential Revision: D43538804 fbshipit-source-id: 0aeca40c1c2a625eca5d60e466eb24df30453ba7
31 lines
1.1 KiB
C++
31 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "NativeViewConfigProviderBinding.h"
|
|
|
|
namespace facebook::react::NativeViewConfigProviderBinding {
|
|
|
|
void install(jsi::Runtime &runtime, ProviderType &&provider) {
|
|
auto name = "RN$NativeComponentRegistry_getNativeViewConfig";
|
|
auto hostFunction = [provider = std::move(provider)](
|
|
jsi::Runtime &runtime,
|
|
jsi::Value const & /*thisValue*/,
|
|
jsi::Value const *args,
|
|
size_t count) -> jsi::Value {
|
|
if (count != 1 || !args[0].isString()) {
|
|
throw new jsi::JSError(runtime, "1 argument of type String expected.");
|
|
}
|
|
return provider(args[0].getString(runtime).utf8(runtime));
|
|
};
|
|
|
|
auto jsiFunction = jsi::Function::createFromHostFunction(
|
|
runtime, jsi::PropNameID::forAscii(runtime, name), 2, hostFunction);
|
|
|
|
runtime.global().setProperty(runtime, name, jsiFunction);
|
|
}
|
|
} // namespace facebook::react::NativeViewConfigProviderBinding
|