는 네이티브 반응, 내가 지금처럼의 TextInput에서 확장하는 사용자 정의 구성 요소가 사용하는 함수가 아닙니다 반작용 :는 기본 _this2.refs.myinput.focus가
TextBox.js을
...
render() {
return (
<TextInput
{...this.props}
style={styles.textBox}/>
);
}
...
MyScene.js (수입 TextBox.js)
...
render() {
render(
<View>
<TextBox
rel='MyFirstInput'
returnKeyType={'next'}
onSubmitEditing={(event) => { this.refs.MySecondInput.focus(); }}/>
<TextBox
ref='MySecondInput'/>
</View>
);
}
내가 옆에 때 키보드의 응용 프로그램을 누릅니다 구축
_this2.refs.MySecondInput.focus is not a function
오류가 무엇을 할 수 : MyFirstInput
에 초점을 맞추고, 내가 대신 내가 오류를 얻을 초점이 될 MySecondInput
을 기대? 그것은 this
의 범위와 관련이 있습니까? 감사.
저는 React-Native를 사용하고 있지만 대부분 동일한 원칙이 적용됩니다. 'this.refs.SecondInput'을 콘솔에 기록했고 구성 요소가 반환되어 구성 요소가 반환되었으므로 작동하지 않는'.focus()'함수에 불과합니다. –
그들은 실제로 반응 문서에 대한 refs에 대해 설명 할 때 .focus()를 구현했습니다. 이 [es6 예] (https://facebook.github.io/react/docs/more-about-refs.html)를 살펴보십시오. – Kevin