diff --git a/boilerplate/app/components/Text.tsx b/boilerplate/app/components/Text.tsx index 88ab96515..1b9d4db87 100644 --- a/boilerplate/app/components/Text.tsx +++ b/boilerplate/app/components/Text.tsx @@ -1,5 +1,5 @@ import i18n from "i18n-js" -import React from "react" +import React, { ForwardedRef, PropsWithChildren, forwardRef } from "react" import { StyleProp, Text as RNText, TextProps as RNTextProps, TextStyle } from "react-native" import { isRTL, translate, TxKeyPath } from "../i18n" import { colors, typography } from "../theme" @@ -51,7 +51,10 @@ export interface TextProps extends RNTextProps { * @param {TextProps} props - The props for the `Text` component. * @returns {JSX.Element} The rendered `Text` component. */ -export function Text(props: TextProps) { +export const Text = forwardRef(function Text( + props: PropsWithChildren, + ref: ForwardedRef, +) { const { weight, size, tx, txOptions, text, children, style: $styleOverride, ...rest } = props const i18nText = tx && translate(tx, txOptions) @@ -67,11 +70,11 @@ export function Text(props: TextProps) { ] return ( - + {content} ) -} +}) const $sizeStyles = { xxl: { fontSize: 36, lineHeight: 44 } satisfies TextStyle, diff --git a/boilerplate/app/screens/DemoCommunityScreen.tsx b/boilerplate/app/screens/DemoCommunityScreen.tsx index 900e24d54..dd24fca90 100644 --- a/boilerplate/app/screens/DemoCommunityScreen.tsx +++ b/boilerplate/app/screens/DemoCommunityScreen.tsx @@ -1,5 +1,5 @@ -import React, { FC } from "react" -import { Image, ImageStyle, TextStyle, View, ViewStyle } from "react-native" +import React, { FC, useRef } from "react" +import { Image, ImageStyle, TextStyle, View, ViewStyle, Text as RNText } from "react-native" import { ListItem, Screen, Text } from "../components" import { DemoTabScreenProps } from "../navigators/DemoNavigator" import { spacing } from "../theme" @@ -13,9 +13,11 @@ const reactNativeNewsletterLogo = require("../../assets/images/demo/rnn-logo.png export const DemoCommunityScreen: FC> = function DemoCommunityScreen(_props) { + const textRef = useRef(null) + return ( - +