mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4d04b1d4c8
Summary: Changelog: [internal] This replaces all direct references to the `ReactNative` module (which is the Paper renderer) to `RendererProxy` which would select between Paper and Fabric correctly. The implementation of these functions is exactly the same right now. As per the removal of the fix for T55744311 in `ScrollView`, I verified this doesn't cause any issues in the screen where it failed before. Reviewed By: javache Differential Revision: D39270691 fbshipit-source-id: 03882748fe4b754b9a2c5e9d4c4f003b94ed49ef
30 lines
752 B
JavaScript
30 lines
752 B
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
const {dispatchCommand} = require('../ReactNative/RendererProxy');
|
|
|
|
type Options<T = string> = $ReadOnly<{|
|
|
supportedCommands: $ReadOnlyArray<T>,
|
|
|}>;
|
|
|
|
function codegenNativeCommands<T: interface {}>(options: Options<$Keys<T>>): T {
|
|
const commandObj: {[$Keys<T>]: (...$ReadOnlyArray<mixed>) => void} = {};
|
|
|
|
options.supportedCommands.forEach(command => {
|
|
commandObj[command] = (ref, ...args) => {
|
|
dispatchCommand(ref, command, args);
|
|
};
|
|
});
|
|
|
|
return ((commandObj: any): T);
|
|
}
|
|
|
|
export default codegenNativeCommands;
|