Summary: This change adds the template for a RNW module to the existing react-native flipper project. Basically, the changes in this diff are the product of executing the react-native-windows init for the existing library. See: https://microsoft.github.io/react-native-windows/docs/getting-started https://microsoft.github.io/react-native-windows/docs/native-modules-setup Notes: There's some auto-generated module code contained in this change: ReactNativeModule (.h/.cpp) allow-large-files Reviewed By: passy Differential Revision: D36751772 fbshipit-source-id: 41207bedb00ea147883f6d13336ed6c1da4454d7
43 lines
1.1 KiB
C++
43 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "JSValue.h"
|
|
#include "NativeModules.h"
|
|
|
|
using namespace winrt::Microsoft::ReactNative;
|
|
|
|
namespace winrt::ReactNativeFlipper {
|
|
|
|
REACT_MODULE(ReactNativeModule, L"ReactNativeFlipper")
|
|
struct ReactNativeModule {
|
|
// See https://microsoft.github.io/react-native-windows/docs/native-modules
|
|
// for details on writing native modules
|
|
|
|
REACT_INIT(Initialize)
|
|
void Initialize(ReactContext const& reactContext) noexcept {
|
|
m_reactContext = reactContext;
|
|
}
|
|
|
|
REACT_METHOD(sampleMethod)
|
|
void sampleMethod(
|
|
std::string stringArgument,
|
|
int numberArgument,
|
|
std::function<void(std::string)>&& callback) noexcept {
|
|
// TODO: Implement some actually useful functionality
|
|
callback(
|
|
"Received numberArgument: " + std::to_string(numberArgument) +
|
|
" stringArgument: " + stringArgument);
|
|
}
|
|
|
|
private:
|
|
ReactContext m_reactContext{nullptr};
|
|
};
|
|
|
|
} // namespace winrt::ReactNativeFlipper
|