Skip to main content

getNativePropsForTNode

export
function getNativePropsForTNode<
  T extends TText
  | TBlock
  | TPhrasing
>(
  props: TDefaultRendererProps<T>
) : ViewProps & {
  onPress?: () => void;
} | TextProps

Extract React Native props for a given ​TNode, such as those which would be passed to Text, View or GenericPressable by TDefaultRenderer.

This helper function is peculiarly useful when one wants a custom renderer which uses a different native component, for example Animated.Text instead of default Text.

Example#

import React from 'react';
import { Animated } from 'react-native';
import { CustomTextualRenderer, getNativePropsForTNode } from 'react-native-render-html';
const AnimatedSpanRenderer: CustomTextualRenderer = (props) => {
const nativeProps = getNativePropsForTNode(props);
// This is equivalent to a TDefaultRenderer which `Text` is replaced
// with Animated.Text
return <Animated.Text {...nativeProps} />;
}

Type Parameters#

T#

Parameters#

props#

required