mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
RN: Change onlyChild => React.Children.only
Reviewed By: sebmarkbage Differential Revision: D4025440 fbshipit-source-id: efbcb44dcc89a6059688cf5a00cf28ada8a6a4c4
This commit is contained in:
committed by
Facebook Github Bot
parent
331c13d4dc
commit
c4fc13b997
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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<any> {
|
||||
// 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',
|
||||
|
||||
Reference in New Issue
Block a user