탭 을 캡처하는 방법이 있습니다에서TextInput . 해 키지 만 아무것도 아닌 것보다 낫습니다 .
onChangeText새 입력 값을 이전 값과 비교하여 a를 확인 하는 핸들러를 정의하십시오 \t. 발견 된 경우 @boredgames에 표시된대로 필드를 진행하십시오.
변수 username에 사용자 이름 값이 포함되어 있고 setUsername상점 (구성 요소 상태, redux 상점 등)에서 변경하기위한 조치를 전달 한다고 가정하면 다음과 같이하십시오.
function tabGuard (newValue, oldValue, callback, nextCallback) {
if (newValue.indexOf('\t') >= 0 && oldValue.indexOf('\t') === -1) {
callback(oldValue)
nextCallback()
} else {
callback(newValue)
}
}
class LoginScene {
focusNextField = (nextField) => {
this.refs[nextField].focus()
}
focusOnPassword = () => {
this.focusNextField('password')
}
handleUsernameChange = (newValue) => {
const { username } = this.props // or from wherever
const { setUsername } = this.props.actions // or from wherever
tabGuard(newValue, username, setUsername, this.focusOnPassword)
}
render () {
const { username } = this.props
return (
<TextInput ref='username'
placeholder='Username'
autoCapitalize='none'
autoCorrect={false}
autoFocus
keyboardType='email-address'
onChangeText={handleUsernameChange}
blurOnSubmit={false}
onSubmitEditing={focusOnPassword}
value={username} />
)
}
}