From 5f8d7ac61817f7cb9fa08a39c513a1114f69746e Mon Sep 17 00:00:00 2001 From: Horcrux Date: Thu, 22 Dec 2016 16:13:33 -0800 Subject: [PATCH] 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 --- Libraries/Components/Touchable/TouchableWithoutFeedback.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index c515613e843..8059c7e1df5 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -157,9 +157,7 @@ const TouchableWithoutFeedback = React.createClass({ ((child._owner && child._owner.getName && child._owner.getName()) || '') ); 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') ?