From fec0c598c2a2eaa4c98a4137bdecbd88eddf2062 Mon Sep 17 00:00:00 2001 From: Daniele Zannotti Date: Tue, 31 Mar 2015 00:02:16 +0100 Subject: [PATCH] added constraint of child type to touchablewithoutfeedback to match touchhighlight --- .../Touchable/TouchableWithoutFeedback.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) mode change 100644 => 100755 Libraries/Components/Touchable/TouchableWithoutFeedback.js diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js old mode 100644 new mode 100755 index 1b1178ebbe4ff9..8efa61c93f8396 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -13,8 +13,10 @@ var React = require('React'); var Touchable = require('Touchable'); - +var keyOf = require('keyOf'); var onlyChild = require('onlyChild'); +var cloneWithProps = require('cloneWithProps'); +var ensureComponentIsNative = require('ensureComponentIsNative'); /** * When the scroll view is disabled, this defines how far your touch may move @@ -49,6 +51,14 @@ var TouchableWithoutFeedback = React.createClass({ return this.touchableGetInitialState(); }, + componentDidMount: function() { + ensureComponentIsNative(this.refs[CHILD_REF]); + }, + + componentDidUpdate: function() { + ensureComponentIsNative(this.refs[CHILD_REF]); + }, + /** * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are * defined on your component. @@ -78,8 +88,15 @@ var TouchableWithoutFeedback = React.createClass({ }, render: function(): ReactElement { - // Note(vjeux): use cloneWithProps once React has been upgraded - var child = onlyChild(this.props.children); + var child = cloneWithProps( + onlyChild(this.props.children), + { + ref: CHILD_REF, + accessible: true, + testID: this.props.testID, + } + ); + // Note(avik): remove dynamic typecast once Flow has been upgraded return (React: any).cloneElement(child, { accessible: true, @@ -94,4 +111,6 @@ var TouchableWithoutFeedback = React.createClass({ } }); +var CHILD_REF = keyOf({childRef: null}); + module.exports = TouchableWithoutFeedback;