Files
react-native/Libraries/Utilities/codegenNativeCommands.js
T
Rubén Norte 4d04b1d4c8 Remove last direct references to utilities in Paper from react-native
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
2022-09-08 11:12:06 -07:00

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;