@@ -15,6 +15,7 @@ import color from 'color';
1515import { Style , getLeftStyles , getRightStyles } from './utils' ;
1616import { useInternalTheme } from '../../core/theming' ;
1717import type { $RemoveChildren , EllipsizeProp , ThemeProp } from '../../types' ;
18+ import { forwardRef } from '../../utils/forwardRef' ;
1819import TouchableRipple from '../TouchableRipple/TouchableRipple' ;
1920import Text from '../Typography/Text' ;
2021
@@ -126,24 +127,27 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
126127 *
127128 * @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
128129 */
129- const ListItem = ( {
130- left,
131- right,
132- title,
133- description,
134- onPress,
135- theme : themeOverrides ,
136- style,
137- titleStyle,
138- titleNumberOfLines = 1 ,
139- descriptionNumberOfLines = 2 ,
140- titleEllipsizeMode,
141- descriptionEllipsizeMode,
142- descriptionStyle,
143- descriptionMaxFontSizeMultiplier,
144- titleMaxFontSizeMultiplier,
145- ...rest
146- } : Props ) => {
130+ const ListItem = (
131+ {
132+ left,
133+ right,
134+ title,
135+ description,
136+ onPress,
137+ theme : themeOverrides ,
138+ style,
139+ titleStyle,
140+ titleNumberOfLines = 1 ,
141+ descriptionNumberOfLines = 2 ,
142+ titleEllipsizeMode,
143+ descriptionEllipsizeMode,
144+ descriptionStyle,
145+ descriptionMaxFontSizeMultiplier,
146+ titleMaxFontSizeMultiplier,
147+ ...rest
148+ } : Props ,
149+ ref : React . ForwardedRef < View >
150+ ) => {
147151 const theme = useInternalTheme ( themeOverrides ) ;
148152 const [ alignToTop , setAlignToTop ] = React . useState ( false ) ;
149153
@@ -218,6 +222,7 @@ const ListItem = ({
218222 return (
219223 < TouchableRipple
220224 { ...rest }
225+ ref = { ref }
221226 style = { [ theme . isV3 ? styles . containerV3 : styles . container , style ] }
222227 onPress = { onPress }
223228 theme = { theme }
@@ -249,7 +254,8 @@ const ListItem = ({
249254 ) ;
250255} ;
251256
252- ListItem . displayName = 'List.Item' ;
257+ const Component = forwardRef ( ListItem ) ;
258+ Component . displayName = 'List.Item' ;
253259
254260const styles = StyleSheet . create ( {
255261 container : {
@@ -288,4 +294,4 @@ const styles = StyleSheet.create({
288294 } ,
289295} ) ;
290296
291- export default ListItem ;
297+ export default Component ;
0 commit comments