Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions docs/new-architecture-library-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,18 @@ class MyComponent extends React.Component<Props> {
**Creating the NativeCommands with `codegenNativeCommands`**

```ts title="MyCustomMapNativeComponent.js"
import codegeNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
...
type Props = {...};
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';

const MyCustomMapNativeComponent: HostComponent<Props> =
requireNativeComponent<Props>('MyCustomMapNativeComponent');
type MyCustomMapNativeComponentType = HostComponent<NativeProps>;

interface NativeCommands {
moveToRegion: (
ref: React.ElementRef<typeof MyCustomMapNativeComponent>,
region: MapRegion,
duration: number,
) => void;
}
+moveToRegion: (
viewRef: React.ElementRef<MyCustomMapNativeComponentType>,
region: MapRegion,
duration: number,
) => void;
}

export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['moveToRegion'],
Expand Down