diff --git a/Libraries/Components/StaticContainer.js b/Libraries/Components/StaticContainer.js index 64964e842..a29593ae4 100644 --- a/Libraries/Components/StaticContainer.js +++ b/Libraries/Components/StaticContainer.js @@ -11,16 +11,14 @@ */ 'use strict'; -var React = require('React'); - -var onlyChild = require('react/lib/onlyChild'); +const React = require('React'); /** * Renders static content efficiently by allowing React to short-circuit the * reconciliation process. This component should be used when you know that a * subtree of components will never need to be updated. * - * var someValue = ...; // We know for certain this value will never change. + * const someValue = ...; // We know for certain this value will never change. * return ( * * @@ -37,8 +35,10 @@ class StaticContainer extends React.Component { } render() { - var child = this.props.children; - return (child === null || child === false) ? null : onlyChild(child); + const child = this.props.children; + return (child === null || child === false) + ? null + : React.Children.only(child); } } diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 314a14283..309da5dd3 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -27,7 +27,6 @@ var ensureComponentIsNative = require('ensureComponentIsNative'); var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); var keyOf = require('fbjs/lib/keyOf'); var merge = require('merge'); -var onlyChild = require('react/lib/onlyChild'); type Event = Object; @@ -243,7 +242,7 @@ var TouchableHighlight = React.createClass({ onResponderTerminate={this.touchableHandleResponderTerminate} testID={this.props.testID}> {React.cloneElement( - onlyChild(this.props.children), + React.Children.only(this.props.children), { ref: CHILD_REF, } diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js index 7a28011b1..635aebfa5 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js @@ -19,7 +19,6 @@ var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); var UIManager = require('UIManager'); var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var onlyChild = require('react/lib/onlyChild'); var processColor = require('processColor'); var requireNativeComponent = require('requireNativeComponent'); @@ -222,7 +221,7 @@ var TouchableNativeFeedback = React.createClass({ }, render: function() { - const child = onlyChild(this.props.children); + const child = React.Children.only(this.props.children); let children = child.props.children; if (Touchable.TOUCH_TARGET_DEBUG && child.type.displayName === 'View') { if (!Array.isArray(children)) { diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index c04e7a49f..383bc7643 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -18,7 +18,6 @@ const Touchable = require('Touchable'); const View = require('View'); const ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -const onlyChild = require('react/lib/onlyChild'); const warning = require('fbjs/lib/warning'); type Event = Object; @@ -150,7 +149,7 @@ const TouchableWithoutFeedback = React.createClass({ render: function(): React.Element { // Note(avik): remove dynamic typecast once Flow has been upgraded - const child = onlyChild(this.props.children); + const child = React.Children.only(this.props.children); let children = child.props.children; warning( !child.type || child.type.displayName !== 'Text',