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
This commit is contained in:
Eli White
2019-11-15 14:02:40 -08:00
committed by Facebook Github Bot
parent 854fa96cae
commit b7bd85a2bf
+22 -28
View File
@@ -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 = (
<RCTTextInputView
ref={this._setNativeRef}
{...props}
{...this.props}
onFocus={this._onFocus}
onBlur={this._onBlur}
onChange={this._onChange}
@@ -905,15 +902,16 @@ const TextInput = createReactClass({
onSelectionChange={this._onSelectionChange}
onTextInput={this._onTextInput}
onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
selection={selection}
style={style}
text={this._getText()}
dataDetectorTypes={this.props.dataDetectorTypes}
onScroll={this._onScroll}
/>
);
} 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 = <Text>{children}</Text>;
}
if (props.selection && props.selection.end == null) {
props.selection = {
start: props.selection.start,
end: props.selection.start,
};
}
textInput = (
<AndroidTextInput
ref={this._setNativeRef}
{...props}
{...this.props}
autoCapitalize={autoCapitalize}
mostRecentEventCount={0}
onFocus={this._onFocus}
onBlur={this._onBlur}
onChange={this._onChange}
onSelectionChange={this._onSelectionChange}
onTextInput={this._onTextInput}
selection={selection}
style={style}
text={this._getText()}
children={children}
disableFullscreenUI={this.props.disableFullscreenUI}