From b7bd85a2bf8d513b6669a3f60780cdf142715e24 Mon Sep 17 00:00:00 2001 From: Eli White Date: Fri, 15 Nov 2019 13:58:48 -0800 Subject: [PATCH] Refactor to not copy props Summary: We don't need a local mutable copy of props. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D18435731 fbshipit-source-id: 13ec1a78ca26b1372a4aed484a821204a93b6437 --- Libraries/Components/TextInput/TextInput.js | 50 +++++++++------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index bdd02f2f168..ea185433392 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -872,32 +872,29 @@ const TextInput = createReactClass({ // This is a hack to let Flow know we want an exact object |} = {...null}; + const selection = + this.props.selection && this.props.selection.end == null + ? { + start: this.props.selection.start, + end: this.props.selection.start, + } + : null; + if (Platform.OS === 'ios') { - const props = Object.assign({}, this.props); - props.style = [this.props.style]; - - if (props.selection && props.selection.end == null) { - props.selection = { - start: props.selection.start, - end: props.selection.start, - }; - } - - const RCTTextInputView = props.multiline + const RCTTextInputView = this.props.multiline ? RCTMultilineTextInputView : RCTSinglelineTextInputView; - if (props.multiline) { - props.style.unshift(styles.multilineInput); - } + const style = this.props.multiline + ? [styles.multilineInput, this.props.style] + : this.props.style; - additionalTouchableProps.rejectResponderTermination = - props.rejectResponderTermination; + additionalTouchableProps.rejectResponderTermination = this.props.rejectResponderTermination; textInput = ( ); } else if (Platform.OS === 'android') { - const props = Object.assign({}, this.props); - props.style = [this.props.style]; - props.autoCapitalize = props.autoCapitalize || 'sentences'; + const style = [this.props.style]; + const autoCapitalize = this.props.autoCapitalize || 'sentences'; let children = this.props.children; let childCount = 0; React.Children.forEach(children, () => ++childCount); @@ -925,23 +923,19 @@ const TextInput = createReactClass({ children = {children}; } - if (props.selection && props.selection.end == null) { - props.selection = { - start: props.selection.start, - end: props.selection.start, - }; - } - textInput = (