@@ -2,6 +2,8 @@ import { TBlock, TPhrasing, TText } from '@native-html/transient-render-engine';
22import { TextProps , ViewProps } from 'react-native' ;
33import { TDefaultRendererProps } from '../shared-types' ;
44
5+ const empty : any = { } ;
6+
57/**
68 * Extract React Native props for a given {@link TNode}. Native props target
79 * either `Text` or `View` elements, with an optional `onPress` prop for
@@ -11,14 +13,20 @@ import { TDefaultRendererProps } from '../shared-types';
1113 */
1214export default function getNativePropsForTNode <
1315 T extends TPhrasing | TText | TBlock
14- > ( props : TDefaultRendererProps < T > ) : T extends TBlock ? ViewProps : TextProps {
16+ > (
17+ props : TDefaultRendererProps < T >
18+ ) : T extends TBlock ? ViewProps & { onPress ?: ( ) => void } : TextProps {
1519 const { tnode, style, type, nativeProps, onPress } = props ;
1620 const switchProp = type === 'block' ? props . viewProps : props . textProps ;
21+ const propsFromModel =
22+ tnode . getReactNativeProps ( ) ?. [ type === 'block' ? 'view' : 'text' ] || empty ;
23+ const syntheticOnPress =
24+ onPress ?? nativeProps ?. onPress ?? propsFromModel . onPress ;
1725 const nextProps : TextProps | ViewProps = {
18- ...( typeof onPress === 'function'
26+ ...( typeof syntheticOnPress === 'function'
1927 ? ( { accessibilityRole : type === 'block' ? 'button' : 'link' } as const )
2028 : null ) ,
21- ...tnode . getReactNativeProps ( ) ?. [ type === 'block' ? 'view' : 'text' ] ,
29+ ...propsFromModel ,
2230 ...nativeProps ,
2331 ...switchProp ,
2432 onPress,
0 commit comments