Skip to content

Commit a1a220b

Browse files
fix(boilerplate): Allow passing a ref prop to the Text component (#2909 by @Aniganesh)
* Update post ignite X release. Add useful demo * fix formatting issues * Remove unnecessary demo, translations, undo unintended changes to fr i18n * fix formatting * fix failing test * remove unused imports * restore translations to earlier state --------- Co-authored-by: Aniruddha <[email protected]>
1 parent 1dce615 commit a1a220b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

boilerplate/app/components/Text.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isRTL, translate, TxKeyPath } from "@/i18n"
44
import type { ThemedStyle, ThemedStyleArray } from "@/theme"
55
import { useAppTheme } from "@/utils/useAppTheme"
66
import { typography } from "@/theme/typography"
7-
import { ReactNode } from "react"
7+
import { ReactNode, forwardRef, ForwardedRef } from "react"
88

99
type Sizes = keyof typeof $sizeStyles
1010
type Weights = keyof typeof typography.primary
@@ -53,7 +53,7 @@ export interface TextProps extends RNTextProps {
5353
* @param {TextProps} props - The props for the `Text` component.
5454
* @returns {JSX.Element} The rendered `Text` component.
5555
*/
56-
export function Text(props: TextProps) {
56+
export const Text = forwardRef(function Text(props: TextProps, ref: ForwardedRef<RNText>) {
5757
const { weight, size, tx, txOptions, text, children, style: $styleOverride, ...rest } = props
5858
const { themed } = useAppTheme()
5959

@@ -70,11 +70,11 @@ export function Text(props: TextProps) {
7070
]
7171

7272
return (
73-
<RNText {...rest} style={$styles}>
73+
<RNText {...rest} style={$styles} ref={ref}>
7474
{content}
7575
</RNText>
7676
)
77-
}
77+
})
7878

7979
const $sizeStyles = {
8080
xxl: { fontSize: 36, lineHeight: 44 } satisfies TextStyle,

0 commit comments

Comments
 (0)