Skip to content

Commit e758cb7

Browse files
sherginfacebook-github-bot
authored andcommittedJan 15, 2018
Prettier for TextInput.js
Summary: Trivial. Reviewed By: sahrens Differential Revision: D6690929 fbshipit-source-id: 82906cd4a0eec320f998661ed48b9352b9b72670
1 parent 83ed9d1 commit e758cb7

File tree

1 file changed

+62
-38
lines changed

1 file changed

+62
-38
lines changed
 

‎Libraries/Components/TextInput/TextInput.js

+62-38
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*
99
* @providesModule TextInput
1010
* @flow
11+
* @format
1112
*/
1213
'use strict';
1314

@@ -50,8 +51,14 @@ const onlyMultiline = {
5051
if (Platform.OS === 'android') {
5152
var AndroidTextInput = requireNativeComponent('AndroidTextInput', null);
5253
} else if (Platform.OS === 'ios') {
53-
var RCTMultilineTextInputView = requireNativeComponent('RCTMultilineTextInputView', null);
54-
var RCTSinglelineTextInputView = requireNativeComponent('RCTSinglelineTextInputView', null);
54+
var RCTMultilineTextInputView = requireNativeComponent(
55+
'RCTMultilineTextInputView',
56+
null,
57+
);
58+
var RCTSinglelineTextInputView = requireNativeComponent(
59+
'RCTSinglelineTextInputView',
60+
null,
61+
);
5562
}
5663

5764
type Event = Object;
@@ -279,11 +286,7 @@ const TextInput = createReactClass({
279286
* Determines the color of the keyboard.
280287
* @platform ios
281288
*/
282-
keyboardAppearance: PropTypes.oneOf([
283-
'default',
284-
'light',
285-
'dark',
286-
]),
289+
keyboardAppearance: PropTypes.oneOf(['default', 'light', 'dark']),
287290
/**
288291
* Determines how the return key should look. On Android you can also use
289292
* `returnKeyLabel`.
@@ -448,8 +451,8 @@ const TextInput = createReactClass({
448451
*/
449452
secureTextEntry: PropTypes.bool,
450453
/**
451-
* The highlight and cursor color of the text input.
452-
*/
454+
* The highlight and cursor color of the text input.
455+
*/
453456
selectionColor: ColorPropType,
454457
/**
455458
* An instance of `DocumentSelectionState`, this is some state that is responsible for
@@ -603,8 +606,10 @@ const TextInput = createReactClass({
603606
* Returns `true` if the input is currently focused; `false` otherwise.
604607
*/
605608
isFocused: function(): boolean {
606-
return TextInputState.currentlyFocusedField() ===
607-
ReactNative.findNodeHandle(this._inputRef);
609+
return (
610+
TextInputState.currentlyFocusedField() ===
611+
ReactNative.findNodeHandle(this._inputRef)
612+
);
608613
},
609614

610615
contextTypes: {
@@ -627,13 +632,13 @@ const TextInput = createReactClass({
627632
}
628633
this._focusSubscription = this.context.focusEmitter.addListener(
629634
'focus',
630-
(el) => {
635+
el => {
631636
if (this === el) {
632637
this.requestAnimationFrame(this.focus);
633638
} else if (this.isFocused()) {
634639
this.blur();
635640
}
636-
}
641+
},
637642
);
638643
if (this.props.autoFocus) {
639644
this.context.onFocusRequested(this);
@@ -652,7 +657,7 @@ const TextInput = createReactClass({
652657
},
653658

654659
childContextTypes: {
655-
isInAParentText: PropTypes.bool
660+
isInAParentText: PropTypes.bool,
656661
},
657662

658663
/**
@@ -671,13 +676,11 @@ const TextInput = createReactClass({
671676
},
672677

673678
_getText: function(): ?string {
674-
return typeof this.props.value === 'string' ?
675-
this.props.value :
676-
(
677-
typeof this.props.defaultValue === 'string' ?
678-
this.props.defaultValue :
679-
''
680-
);
679+
return typeof this.props.value === 'string'
680+
? this.props.value
681+
: typeof this.props.defaultValue === 'string'
682+
? this.props.defaultValue
683+
: '';
681684
},
682685

683686
_setNativeRef: function(ref: any) {
@@ -691,21 +694,26 @@ const TextInput = createReactClass({
691694
props.style = [this.props.style];
692695

693696
if (props.selection && props.selection.end == null) {
694-
props.selection = {start: props.selection.start, end: props.selection.start};
697+
props.selection = {
698+
start: props.selection.start,
699+
end: props.selection.start,
700+
};
695701
}
696702

697703
if (!props.multiline) {
698704
if (__DEV__) {
699705
for (var propKey in onlyMultiline) {
700706
if (props[propKey]) {
701707
const error = new Error(
702-
'TextInput prop `' + propKey + '` is only supported with multiline.'
708+
'TextInput prop `' +
709+
propKey +
710+
'` is only supported with multiline.',
703711
);
704712
warning(false, '%s', error.stack);
705713
}
706714
}
707715
}
708-
textContainer =
716+
textContainer = (
709717
<RCTSinglelineTextInputView
710718
ref={this._setNativeRef}
711719
{...props}
@@ -715,23 +723,28 @@ const TextInput = createReactClass({
715723
onSelectionChange={this._onSelectionChange}
716724
onSelectionChangeShouldSetResponder={emptyFunction.thatReturnsTrue}
717725
text={this._getText()}
718-
/>;
726+
/>
727+
);
719728
} else {
720729
var children = props.children;
721730
var childCount = 0;
722731
React.Children.forEach(children, () => ++childCount);
723732
invariant(
724733
!(props.value && childCount),
725-
'Cannot specify both value and children.'
734+
'Cannot specify both value and children.',
726735
);
727736
if (childCount >= 1) {
728-
children = <Text style={props.style} allowFontScaling={props.allowFontScaling}>{children}</Text>;
737+
children = (
738+
<Text style={props.style} allowFontScaling={props.allowFontScaling}>
739+
{children}
740+
</Text>
741+
);
729742
}
730743
if (props.inputView) {
731744
children = [children, props.inputView];
732745
}
733746
props.style.unshift(styles.multilineInput);
734-
textContainer =
747+
textContainer = (
735748
<RCTMultilineTextInputView
736749
ref={this._setNativeRef}
737750
{...props}
@@ -746,7 +759,8 @@ const TextInput = createReactClass({
746759
text={this._getText()}
747760
dataDetectorTypes={this.props.dataDetectorTypes}
748761
onScroll={this._onScroll}
749-
/>;
762+
/>
763+
);
750764
}
751765

752766
return (
@@ -779,17 +793,20 @@ const TextInput = createReactClass({
779793
React.Children.forEach(children, () => ++childCount);
780794
invariant(
781795
!(this.props.value && childCount),
782-
'Cannot specify both value and children.'
796+
'Cannot specify both value and children.',
783797
);
784798
if (childCount > 1) {
785799
children = <Text>{children}</Text>;
786800
}
787801

788802
if (props.selection && props.selection.end == null) {
789-
props.selection = {start: props.selection.start, end: props.selection.start};
803+
props.selection = {
804+
start: props.selection.start,
805+
end: props.selection.start,
806+
};
790807
}
791808

792-
const textContainer =
809+
const textContainer = (
793810
<AndroidTextInput
794811
ref={this._setNativeRef}
795812
{...props}
@@ -804,7 +821,8 @@ const TextInput = createReactClass({
804821
disableFullscreenUI={this.props.disableFullscreenUI}
805822
textBreakStrategy={this.props.textBreakStrategy}
806823
onScroll={this._onScroll}
807-
/>;
824+
/>
825+
);
808826

809827
return (
810828
<TouchableWithoutFeedback
@@ -875,22 +893,28 @@ const TextInput = createReactClass({
875893
}
876894
},
877895

878-
componentDidUpdate: function () {
896+
componentDidUpdate: function() {
879897
// This is necessary in case native updates the text and JS decides
880898
// that the update should be ignored and we should stick with the value
881899
// that we have in JS.
882900
const nativeProps = {};
883901

884-
if (this._lastNativeText !== this.props.value && typeof this.props.value === 'string') {
902+
if (
903+
this._lastNativeText !== this.props.value &&
904+
typeof this.props.value === 'string'
905+
) {
885906
nativeProps.text = this.props.value;
886907
}
887908

888909
// Selection is also a controlled prop, if the native value doesn't match
889910
// JS, update to the JS value.
890911
const {selection} = this.props;
891-
if (this._lastNativeSelection && selection &&
892-
(this._lastNativeSelection.start !== selection.start ||
893-
this._lastNativeSelection.end !== selection.end)) {
912+
if (
913+
this._lastNativeSelection &&
914+
selection &&
915+
(this._lastNativeSelection.start !== selection.start ||
916+
this._lastNativeSelection.end !== selection.end)
917+
) {
894918
nativeProps.selection = this.props.selection;
895919
}
896920

0 commit comments

Comments
 (0)
Please sign in to comment.