export interface IWEProps { accessibilityLabel: string; onPress?: ((status: string | undefined) => void) | undefined; localePrefix: string; children: JSX.Element[]; style: IWEStyle; type?: string; } class WrappingElement extends React.PureComponent<IWEProps> { render() { const { onPress, children, type, accessibilityLabel, style, } = this.props; return onPress ? ( <TouchableOpacity accessibilityLabel={accessibilityLabel} style={style} type={type} onPress={() => onPress(type)} > { children } </TouchableOpacity> ) : ( <View accessibilityLabel={accessibilityLabel} style={style} type={type} > { children } </View> ); } } Esto es lo que estoy haciendo, y este es un error que obtengo al type prop en View y TouchableOpacity :
La propiedad 'tipo' no existe en el tipo 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
El mensaje de error es sencillo: el type de prop no existe para los componentes View y TouchableOpacity . Los accesorios disponibles para View están documentados aquí . Los accesorios disponibles para TouchableOpacity se documentan aquí .
Dado que no está haciendo nada con el type en WrappingElement más que pasarlo a View y TouchableOpacity y la función onPress , simplemente puede eliminar este accesorio. El siguiente código es equivalente al tuyo, pero no arroja el error de tipo.
export interface IWEProps { accessibilityLabel: string; onPress?: ((status: string | undefined) => void) | undefined; localePrefix: string; children: JSX.Element[]; style: IWEStyle; type?: string; } class WrappingElement extends React.PureComponent<IWEProps> { render() { const { onPress, children, type, accessibilityLabel, style, } = this.props; return onPress ? ( <TouchableOpacity accessibilityLabel={accessibilityLabel} style={style} onPress={() => onPress(type)} > { children } </TouchableOpacity> ) : ( <View accessibilityLabel={accessibilityLabel} style={style} > { children } </View> ); } }