【发布时间】:2019-01-01 01:49:45
【问题描述】:
我使用ref 能够通过<ScrollView> 中的一个标签
该代码有效,但我不断收到此流程错误
Cannot assign input to this.inputs.emailInput because null [1] is
incompatible with object literal [2].
src/authentication/containers/SignIn.js
[ .2] 105│ emailInput: {},
:
199│ }}
200│ placeholder={I18n.t('email')}
201│ ref={(input) => {
202│ this.inputs.emailInput = input;
203│ }}
204│ returnKeyType={'next'}
205│ style={styles.textInput}
/private/tmp/flow/flowlib_3c65178/react.js
[1] 184│ | ((React$ElementRef<ElementType> | null) => mixed)
这里是相关代码
输入定义: 在我的反应组件中
inputs= {
lastNameInput: {},
emailInput: {},
postalCodeInput: {},
phoneNumberInput: {},
};
render() 函数中的 <TextInput> 元素:
<TextInput
blurOnSubmit={false}
onChangeText={text => this.setState({ lastName: text })}
onSubmitEditing={() => {
this.inputs.emailInput.focus();
}}
placeholder={I18n.t('lastName')}
ref={(input) => this.inputs.lastNameInput = input}
returnKeyType={'next'}
style={styles.textInput}
underlineColorAndroid="transparent"
value={lastName}
/>
【问题讨论】:
标签: react-native flowtype