Skip to content

Commit 31d6a69

Browse files
richardcannfacebook-github-bot
authored andcommitted
Removing TimerMixin on TextInput (#21522)
Summary: Related to #21485. Removed TimerMixin from Libraries/Components/TextInput/TextInput.js Pull Request resolved: #21522 Differential Revision: D10229669 Pulled By: RSNara fbshipit-source-id: 45de331203eddce06b8fb7ddf4080869c07b6c55
1 parent de416e7 commit 31d6a69

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Libraries/Components/TextInput/TextInput.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const StyleSheet = require('StyleSheet');
2222
const Text = require('Text');
2323
const TextAncestor = require('TextAncestor');
2424
const TextInputState = require('TextInputState');
25-
const TimerMixin = require('react-timer-mixin');
2625
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
2726
const UIManager = require('UIManager');
2827

@@ -803,7 +802,7 @@ const TextInput = createReactClass({
803802
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
804803
* make `this` look like an actual native component class.
805804
*/
806-
mixins: [NativeMethodsMixin, TimerMixin],
805+
mixins: [NativeMethodsMixin],
807806

808807
/**
809808
* Returns `true` if the input is currently focused; `false` otherwise.
@@ -819,6 +818,7 @@ const TextInput = createReactClass({
819818
_focusSubscription: (undefined: ?Function),
820819
_lastNativeText: (undefined: ?string),
821820
_lastNativeSelection: (undefined: ?Selection),
821+
_rafId: (null: ?AnimationFrameID),
822822

823823
componentDidMount: function() {
824824
this._lastNativeText = this.props.value;
@@ -833,7 +833,7 @@ const TextInput = createReactClass({
833833
'focus',
834834
el => {
835835
if (this === el) {
836-
this.requestAnimationFrame(this.focus);
836+
this._rafId = requestAnimationFrame(this.focus);
837837
} else if (this.isFocused()) {
838838
this.blur();
839839
}
@@ -844,7 +844,7 @@ const TextInput = createReactClass({
844844
}
845845
} else {
846846
if (this.props.autoFocus) {
847-
this.requestAnimationFrame(this.focus);
847+
this._rafId = requestAnimationFrame(this.focus);
848848
}
849849
}
850850
},
@@ -858,6 +858,9 @@ const TextInput = createReactClass({
858858
if (tag != null) {
859859
TextInputState.unregisterInput(tag);
860860
}
861+
if (this._rafId != null) {
862+
cancelAnimationFrame(this._rafId);
863+
}
861864
},
862865

863866
contextTypes: {

0 commit comments

Comments
 (0)