Skip to content

fix: support ReactNode children in TouchableRipple#4896

Open
skainguyen1412 wants to merge 1 commit intocallstack:mainfrom
skainguyen1412:fix/touchableripple-children
Open

fix: support ReactNode children in TouchableRipple#4896
skainguyen1412 wants to merge 1 commit intocallstack:mainfrom
skainguyen1412:fix/touchableripple-children

Conversation

@skainguyen1412
Copy link
Copy Markdown

Motivation

TouchableRipple documentation says children can be either a ReactNode or a render function:

children: ((state: PressableStateCallbackType) => React.ReactNode) | React.ReactNode

However, the implementation was still using React.Children.only(...), which made the component stricter than the documented API. That caused valid cases such as function children and multiple children to fail instead of rendering correctly.

This change aligns the implementation with the documented contract by resolving function children and rendering the resulting ReactNode directly.

Related issue

Closes #4873

Test plan

  • Run yarn typescript
  • Run yarn test src/components/__tests__/TouchableRipple.test.tsx --runInBand
  • Run yarn test

Added regression coverage for:

  • normal children
  • function children
  • array children
  • function children returning an array
  • function style

@callstack-bot
Copy link
Copy Markdown

Hey @skainguyen1412, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native implementation of TouchableRipple doesn't support children and style as functions

2 participants