Skip to content

fix(ListItem): align Content and Title prop types with what they render#4034

Open
patrickwehbe wants to merge 1 commit into
react-native-elements:nextfrom
patrickwehbe:fix/listitem-content-title-prop-types
Open

fix(ListItem): align Content and Title prop types with what they render#4034
patrickwehbe wants to merge 1 commit into
react-native-elements:nextfrom
patrickwehbe:fix/listitem-content-title-prop-types

Conversation

@patrickwehbe

Copy link
Copy Markdown

Motivation

Fixes #3893.

Two ListItem subcomponents declare prop types that don't match the element they render, so following the docs for extending the theme's TextProps produces TypeScript errors.

  • ListItem.Content renders a <View> (and its JSDoc says "Receives all View props"), but ListItemContentProps extended TextProps. Text-only props were accepted by the type checker and then silently dropped at runtime by the View, while real View props were rejected.
  • ListItem.Title renders the rneui <Text> component, but ListItemTitleProps extended react-native's TextProps instead of rneui's ../Text TextProps. As a result the rneui-specific props (h1h4, h1Style, ...) and any user-extended themed TextProps could not be passed to ListItem.Title, even though ListItem.Content accepted them.

This matches the report in the issue: the extra props ended up usable on Content (where they do nothing) but not on Title (where they belong).

Changes

  • ListItem.Content.tsx: ListItemContentProps now extends ViewProps (from react-native).
  • ListItem.Title.tsx: ListItemTitleProps now extends TextProps from ../Text (rneui) instead of react-native.

Breaking change

Changing ListItem.Content from TextProps to ViewProps is a breaking change to that component's public prop types. Code that passed Text-only props to ListItem.Content will now get a type error. In practice those props were ignored at runtime already (the component renders a View), so this only surfaces an existing mismatch, but it is a type-level breaking change and I wanted to call it out explicitly in case you'd prefer to land it with the next major. The Title change is additive (it widens the accepted props), not breaking.

I kept the diff intentionally minimal. ListItem.Subtitle has the same react-native-vs-rneui TextProps mismatch as Title; I left it out to keep this PR focused, but I'm happy to include it here or in a follow-up if you'd like.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — applies to ListItem.Content only

Test Plan

  • yarn install
  • yarn typescript (tsc --noEmit) passes on the full repo with the fix applied.
  • Reverting just the two source changes makes tsc fail (e.g. 'h1' does not exist in type 'ListItemTitleProps'), confirming the fix is what resolves the mismatch.

ListItem.Content renders a View but its props extended TextProps, so
View props were rejected by the type checker while Text-only props were
accepted and silently ignored at runtime. Change ListItemContentProps to
extend ViewProps.

ListItem.Title renders the rneui Text component but its props extended
react-native's TextProps, so the extra rneui props (h1-h4, h1Style, ...)
could not be passed. Change ListItemTitleProps to extend the rneui
../Text TextProps.

Note: extending ViewProps instead of TextProps on ListItem.Content is a
breaking change to that component's public types.

Fixes react-native-elements#3893
@theianmay theianmay self-assigned this Jun 21, 2026
@theianmay
theianmay self-requested a review June 21, 2026 16:59
@theianmay theianmay added the component: ListItem Issue related to ListItem Component label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: ListItem Issue related to ListItem Component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextProps are extended by ListItem.Content instead of ListItem.Title

2 participants