react-native - 输入符号后,redux-form 的 React-native Input HOC 失去焦点
问题描述
我正在尝试使用 redux-form,但是,当我阅读时,我需要 HOC 用于输入字段以将 onTextChange 替换为 onChange。我有:
import React from 'react';
import {Input} from 'native-base';
export default function InputField(props) {
const { input, ...inputProps } = props;
return (
<Input
{...inputProps}
onChangeText={input.onChange}
onBlur={input.onBlur}
onFocus={input.onFocus}
value={input.value}
/>
);
};
并以我的形式使用它:
<Item style={{marginTop: 10, width: "100%"}}>
<Field name="login" component={(props) => {
return (
<InputField {...props} keyboardType="email-address" placeholder='E-mail' />
)
}}/>
</Item>
但是每次我键入键时,该字段都会失去焦点。一些“专家”建议使用 focus() 函数。但是,如果我在其中编辑文本怎么办?有什么解决办法吗?或者也许原生基础具有兼容的文本字段组件?
解决方案
It is strange, but it works ))
function InputFieldEmail(props) {
return <InputField {...props} keyboardType="email-address" placeholder='E-mail' />;
}
and use it instead arrow functions
<Field name="login" component={InputFieldEmail}/>
I think it's strange )
推荐阅读
- webpack - 如何将 normalize.css 与 webpack 样式加载器一起使用?
- karate - karate - 无法从 0.7.0 版开始执行证书选择
- java - java中的所有软引用会一次性清除吗?
- c# - 当授权属性允许列出时,角色返回未授权
- c# - Get CheckedListBox item ValueMember
- python - unable to close aiohttp connection/API. (newbie)
- laravel - Laravel spatie/laravel-permissions Naming Conventions
- excel - 以管理员身份在宏中运行 Powershell 命令(提升)
- java - 尝试使用 java spring boot、hibernate 和 thmyeleaf 来支持 MAMP,但在验证时遇到错误
- google-chrome - 为了同步,如何将本地 Tampermonkey 脚本转换为基于 Web 的脚本?