mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
TextInput: Remove use of legacy context API (#22220)
Summary: This removes the use of the legacy context API in `TextInput`. Nothing in OSS appears to make use of the `focusEmitter`. Pull Request resolved: https://github.com/facebook/react-native/pull/22220 Reviewed By: TheSavior Differential Revision: D13408886 Pulled By: RSNara fbshipit-source-id: 9ae597507ccc26a9bc944a44c1f51b91e73cd637
This commit is contained in:
committed by
Facebook Github Bot
parent
193615a158
commit
94456ed3d8
@@ -12,7 +12,6 @@
|
||||
const DeprecatedColorPropType = require('DeprecatedColorPropType');
|
||||
const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes');
|
||||
const DocumentSelectionState = require('DocumentSelectionState');
|
||||
const EventEmitter = require('EventEmitter');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const Platform = require('Platform');
|
||||
const PropTypes = require('prop-types');
|
||||
@@ -892,26 +891,6 @@ const TextInput = createReactClass({
|
||||
// tag is null only in unit tests
|
||||
TextInputState.registerInput(tag);
|
||||
}
|
||||
|
||||
if (this.context.focusEmitter) {
|
||||
this._focusSubscription = this.context.focusEmitter.addListener(
|
||||
'focus',
|
||||
el => {
|
||||
if (this === el) {
|
||||
this._rafId = requestAnimationFrame(this.focus);
|
||||
} else if (this.isFocused()) {
|
||||
this.blur();
|
||||
}
|
||||
},
|
||||
);
|
||||
if (this.props.autoFocus) {
|
||||
this.context.onFocusRequested(this);
|
||||
}
|
||||
} else {
|
||||
if (this.props.autoFocus) {
|
||||
this._rafId = requestAnimationFrame(this.focus);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
@@ -928,11 +907,6 @@ const TextInput = createReactClass({
|
||||
}
|
||||
},
|
||||
|
||||
contextTypes: {
|
||||
onFocusRequested: PropTypes.func,
|
||||
focusEmitter: PropTypes.instanceOf(EventEmitter),
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all text from the `TextInput`.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user