mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add a simple fabric component example
Summary: This diff adds a very simple example to show the use of new architecture in a component. Changelog: [internal] Reviewed By: cortinico Differential Revision: D32045059 fbshipit-source-id: f388bfb765241122de425fbef61cea0620cd31ac
This commit is contained in:
committed by
Facebook GitHub Bot
parent
85ce4ef4b6
commit
d29f3d2a6b
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
||||
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
||||
import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
|
||||
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
|
||||
import type {Float} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
import * as React from 'react';
|
||||
|
||||
type NativeProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
opacity?: Float,
|
||||
|}>;
|
||||
|
||||
export type MyNativeViewType = HostComponent<NativeProps>;
|
||||
|
||||
interface NativeCommands {
|
||||
+callNativeMethodToChangeBackgroundColor: (
|
||||
viewRef: React.ElementRef<MyNativeViewType>,
|
||||
color: string,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: ['callNativeMethodToChangeBackgroundColor'],
|
||||
});
|
||||
|
||||
export default (codegenNativeComponent<NativeProps>(
|
||||
'RNTMyNativeView',
|
||||
): MyNativeViewType);
|
||||
Reference in New Issue
Block a user