在 react-native 上使用验证器时,未定义的 Redux-forms 不是一个函数 (android)
Redux-forms undefined is not a function when using validators on react-native (android)
我在我的 react-native 项目中使用 redux-forms。
到目前为止一切都很好,但是我在仅在 android 下添加验证器时遇到了这个奇怪的错误(见下图)
它自己的组件是一个 react-native-elements 输入组件,包裹在我的自定义组件 (TextFieldInput)
中
这是我的 redux 表单输入及其验证器的代码
输入
<Field
name="username"
autoCapitalize='none'
returnKeyType="next"
component={TextFieldInput}
validate={[ validator.required('Username is required') ]}
/>
这是我的简单验证器
export const required = message => value => value ? undefined : message
错误信息:
undefined is not a function (evaluating 'toArray(validators)[typeof Symbol==='function'? Symbol.iterator:'@@iterator']()')
据我所知,这是由于某些设备运行时缺少 pollyfils 造成的。More info here
我设法通过导入修复它:
import 'core-js/es6/symbol';
import 'core-js/es6/array';
里面index.android.js
您所要做的就是在 package.json 和 npm install 或 yarn 中添加 core-js。
我在我的 react-native 项目中使用 redux-forms。 到目前为止一切都很好,但是我在仅在 android 下添加验证器时遇到了这个奇怪的错误(见下图)
它自己的组件是一个 react-native-elements 输入组件,包裹在我的自定义组件 (TextFieldInput)
中这是我的 redux 表单输入及其验证器的代码
输入
<Field
name="username"
autoCapitalize='none'
returnKeyType="next"
component={TextFieldInput}
validate={[ validator.required('Username is required') ]}
/>
这是我的简单验证器
export const required = message => value => value ? undefined : message
错误信息:
undefined is not a function (evaluating 'toArray(validators)[typeof Symbol==='function'? Symbol.iterator:'@@iterator']()')
据我所知,这是由于某些设备运行时缺少 pollyfils 造成的。More info here
我设法通过导入修复它:
import 'core-js/es6/symbol';
import 'core-js/es6/array';
里面index.android.js
您所要做的就是在 package.json 和 npm install 或 yarn 中添加 core-js。