import React, { ComponentType, PropsWithChildren } from 'react'; import { Platform } from 'react-native'; import Text, { TextProps } from '../primitives/Text'; import View, { ViewProps } from '../primitives/View'; function createView(nativeProps: ViewProps = {}): ComponentType { return function Dom(props: ViewProps) { return ; }; } export const UL = createView( Platform.select({ web: { role: 'list', }, }) ); if (__DEV__) { UL.displayName = 'UL'; } function isTextProps(props: any): props is TextProps { // Treat
  • as a Text element. return typeof props.children === 'string'; } type LIProps = TextProps | ViewProps; export function LI(props: PropsWithChildren) { if (isTextProps(props)) { const role: LIProps['role'] = Platform.select({ web: 'listitem', default: props.role, }); return ; } const role: LIProps['role'] = Platform.select({ web: 'listitem', default: props.role, }); return ; }