fix Touchables inspector

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 https://github.com/facebook/react-native/pull/11262

Differential Revision: D4329147

fbshipit-source-id: 38c9f78b5a81964efccacc7a08b66dda7acb7dc5
This commit is contained in:
Horcrux 2016-12-22 16:13:33 -08:00 committed by Facebook Github Bot
parent 68f62596a3
commit 5f8d7ac618
1 changed files with 1 additions and 3 deletions

View File

@ -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') ?