问题描述
下午好, 在我更改 react-navigation node_modules 中的 createKeyboardAwareNavigator.js 文件后,我得到 currentFocusedField 使用 FocusedInput。 我在我的项目目录中搜索了 currentFocusedField 的其他实例,但没有。我是否缺少在更改后重建 node_modules 的步骤?
import React from 'react';
import { TextInput } from 'react-native';
export default (Navigator,navigatorConfig) =>
class KeyboardAwareNavigator extends React.Component {
static router = Navigator.router;
static navigationoptions = Navigator.navigationoptions;
_prevIoUslyFocusedTextInput = null;
_handleGestureBegin = () => {
this._prevIoUslyFocusedTextInput = TextInput.State.currentlyFocusedinput();
if (this._prevIoUslyFocusedTextInput) {
TextInput.State.blurTextInput(this._prevIoUslyFocusedTextInput);
}
this.props.onGestureBegin && this.props.onGestureBegin();
};
_handleGestureCanceled = () => {
if (this._prevIoUslyFocusedTextInput) {
TextInput.State.focusTextInput(this._prevIoUslyFocusedTextInput);
}
this.props.onGestureCanceled && this.props.onGestureCanceled();
};
_handleGestureEnd = () => {
this._prevIoUslyFocusedTextInput = null;
this.props.onGestureFinish && this.props.onGestureFinish();
};
_handleTransitionStart = (transitionProps,prevTransitionProps) => {
// Todo: We should not even have received the transition start event
// in the case where the index did not change,I believe. We
// should revisit this after 2.0 release.
if (transitionProps.index !== prevTransitionProps.index) {
const currentField = TextInput.State.currentlyFocusedinput();
if (currentField) {
TextInput.State.blurTextInput(currentField);
}
}
const onTransitionStart =
this.props.onTransitionStart || navigatorConfig.onTransitionStart;
onTransitionStart &&
onTransitionStart(transitionProps,prevTransitionProps);
};
render() {
return (
<Navigator
{...this.props}
onGestureBegin={this._handleGestureBegin}
onGestureCanceled={this._handleGestureCanceled}
onGestureEnd={this._handleGestureEnd}
onTransitionStart={this._handleTransitionStart}
/>
);
}
};
解决方法
问题是 VSCode 有一个奇怪的过滤器,它没有显示我正在搜索的函数的所有实例,但是一旦我更改了过滤器并更改了它工作的所有实例。