Skip to content

Commit

Permalink
fix Touchables inspector
Browse files Browse the repository at this point in the history
Summary:
Fix TouchableWithoutFeedback throw error when touchables inspector is shown in react@15.4.0:
`Attempted to assign to readonly property`
![image](https://cloud.githubusercontent.com/assets/7693239/20824463/14f7bfc8-b898-11e6-9bc3-50434492ee40.png)

Convert children into an array by using React.Children.toArray.
Closes #11262

Differential Revision: D4329147

fbshipit-source-id: 38c9f78b5a81964efccacc7a08b66dda7acb7dc5
  • Loading branch information
magicismight authored and facebook-github-bot committed Dec 23, 2016
1 parent 68f6259 commit 5f8d7ac
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ const TouchableWithoutFeedback = React.createClass({
((child._owner && child._owner.getName && child._owner.getName()) || '<unknown>')
);
if (Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'View') {
if (!Array.isArray(children)) {
children = [children];
}
children = React.Children.toArray(children);
children.push(Touchable.renderDebugView({color: 'red', hitSlop: this.props.hitSlop}));
}
const style = (Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'Text') ?
Expand Down

0 comments on commit 5f8d7ac

Please sign in to comment.