From a4eba830920cab0d178e4e521243e7e36526718b Mon Sep 17 00:00:00 2001 From: Richard Cann Date: Fri, 5 Oct 2018 23:47:13 +0100 Subject: [PATCH 1/2] Removing TimerMixin on TextInput --- Libraries/Components/TextInput/TextInput.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 274833a44b02..d7fc9948df4d 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -22,7 +22,6 @@ const StyleSheet = require('StyleSheet'); const Text = require('Text'); const TextAncestor = require('TextAncestor'); const TextInputState = require('TextInputState'); -const TimerMixin = require('react-timer-mixin'); const TouchableWithoutFeedback = require('TouchableWithoutFeedback'); const UIManager = require('UIManager'); @@ -803,7 +802,7 @@ const TextInput = createReactClass({ * `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We * make `this` look like an actual native component class. */ - mixins: [NativeMethodsMixin, TimerMixin], + mixins: [NativeMethodsMixin], /** * Returns `true` if the input is currently focused; `false` otherwise. @@ -819,6 +818,7 @@ const TextInput = createReactClass({ _focusSubscription: (undefined: ?Function), _lastNativeText: (undefined: ?string), _lastNativeSelection: (undefined: ?Selection), + _rafId: (null: ?AnimationFrameID), componentDidMount: function() { this._lastNativeText = this.props.value; @@ -833,7 +833,7 @@ const TextInput = createReactClass({ 'focus', el => { if (this === el) { - this.requestAnimationFrame(this.focus); + this._rafId = requestAnimationFrame(this.focus); } else if (this.isFocused()) { this.blur(); } @@ -844,7 +844,7 @@ const TextInput = createReactClass({ } } else { if (this.props.autoFocus) { - this.requestAnimationFrame(this.focus); + this._rafId = requestAnimationFrame(this.focus); } } }, @@ -858,6 +858,9 @@ const TextInput = createReactClass({ if (tag != null) { TextInputState.unregisterInput(tag); } + if (this._rafId !== null) { + cancelAnimationFrame(this._rafId); + } }, contextTypes: { From e34a49020407c0612557ccd59b89dc50a015b923 Mon Sep 17 00:00:00 2001 From: Richard Cann Date: Sat, 6 Oct 2018 00:04:33 +0100 Subject: [PATCH 2/2] solved flow error --- Libraries/Components/TextInput/TextInput.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index d7fc9948df4d..cd71083cc08e 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -858,7 +858,7 @@ const TextInput = createReactClass({ if (tag != null) { TextInputState.unregisterInput(tag); } - if (this._rafId !== null) { + if (this._rafId != null) { cancelAnimationFrame(this._rafId); } },