A framework for building native applications using React
Skip cloneElement for Fragment children in TouchableHighlight (#56539)
Summary:
Fixes https://github.com/facebook/react-native/issues/54933.
Passing a `React.Fragment` as the child of `TouchableHighlight` currently produces this warning:
Warning: Invalid prop `style` supplied to `React.Fragment`.
React.Fragment can only have `key` and `children` props.
This happens because `TouchableHighlight` unconditionally calls `cloneElement(child, {style})` on its single child, including when that child is a Fragment.
This PR skips that clone when `child.type === React.Fragment` and renders the Fragment as-is.
That avoids passing an invalid `style` prop to `React.Fragment` while preserving the existing render path for Fragment children.
## Changelog:
[General] [Fixed] - Suppress `React.Fragment` style warning when used as a child of `TouchableHighlight`
Pull Request resolved: https://github.com/facebook/react-native/pull/56539
Test Plan:
- Added a Fantom regression test in `TouchableHighlight-itest.js` that renders `<TouchableHighlight><Fragment>...</Fragment></TouchableHighlight>`
- Verified the expected rendered output
- Verified `console.error` is not called
- `yarn flow focus-check packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js`
- `yarn lint` on the changed files
- `yarn prettier --list-different` on the changed files
Reviewed By: GijsWeterings
Differential Revision: D104224036
Pulled By: javache
fbshipit-source-id: 17289926bc62cda84decaf7154183ff355a03d21 Q
qflen committed
d7b5314bd853679f753379d2233035922bbc8977
Parent: 41fc7fd
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 5/26/2026, 11:34:57 AM