我在 React Native 表单上有几个字段,我希望每次用户使用虚拟键盘验证字段时焦点从一个跳转到下一个。
我想出了类似的东西:
<NamedTextInput
name={'email'}
ref={emailRef}
...
onSubmitEditing={() => passwordRef.current.focus()}
/>
<NamedTextInput
name={'password'}
ref={passwordRef}
...
/>
目前我收到一个 TypeScript 错误:
(property) React.MutableRefObject<null>.current: null
Object is possibly 'null'.ts(2531)
我试图添加!和 ?标记,但它结束于:
Property 'focus' does not exist on type 'never'.ts(2339)
有什么办法解决这个问题吗?
谢谢