import React, { memo, forwardRef, useRef } from 'react'; import { Text as NativeText } from 'react-native'; import { usePropsResolution } from '../../../hooks/useThemeProps'; import type { ITextProps } from './types'; import { useHover } from '@react-native-aria/interactions'; import { mergeRefs } from '../../../utils/mergeRefs'; import { makeStyledComponent } from '../../../utils/styled'; import { useResolvedFontFamily } from '../../../hooks/useResolvedFontFamily'; const StyledText = makeStyledComponent(NativeText); const Text = ({ children, ...props }: ITextProps, ref: any) => { const { isTruncated, noOfLines, bold, italic, sub, highlight, underline, strikeThrough, fontFamily: propFontFamily, fontWeight: propFontWeight, fontStyle: propFontStyle, _hover, fontSize = 'md', ...reslovedProps } = usePropsResolution('Text', props); const _ref = useRef(null); // TODO: might have to add this condition const { isHovered } = useHover({}, _hover ? _ref : null); // const { isHovered } = useHover({}, _ref); let fontFamily = propFontFamily; let fontStyle = italic ? 'italic' : propFontStyle; let fontWeight = bold ? 'bold' : propFontWeight; const resolvedFontFamily = useResolvedFontFamily({ fontFamily, fontWeight, fontStyle, }); return ( {children} ); }; export default memo(forwardRef(Text)); export type { ITextProps };