import { createElement, memo } from 'react'; import type { ViewProps } from 'react-native'; // Lazily required so the package barrel stays importable outside RN. type NativeAirPlayHost = ReturnType< typeof import('react-native-nitro-modules').getHostComponent< NitroAirPlayButtonProps, AirPlayButtonMethods > >; let nativeHost: NativeAirPlayHost | null = null; function nativeAirPlayButton(): NativeAirPlayHost { nativeHost ??= ( require('react-native-nitro-modules') as typeof import('react-native-nitro-modules') ).getHostComponent( 'AirPlayButton', () => AirPlayButtonConfig ); return nativeHost; } import type { AirPlayButtonProps as NitroAirPlayButtonProps, AirPlayButtonMethods, } from '../../specs/AirPlayButton.nitro'; import { AirPlayButtonConfig } from '../../nitrogen-configs'; export interface AirPlayButtonProps extends ViewProps { /** Tint color for the AirPlay icon. Default: system blue. */ tintColor?: string; /** Tint color when AirPlay route is active. */ activeTintColor?: string; } /** iOS only — native AirPlay route picker. Renders an empty view on Android. */ export const AirPlayButton = memo(function AirPlayButton({ tintColor = '', activeTintColor = '', ...viewProps }: AirPlayButtonProps): React.JSX.Element { return createElement(nativeAirPlayButton(), { ...viewProps, tintColor, activeTintColor, }); });