【发布时间】:2016-10-24 08:41:06
【问题描述】:
我正在尝试为redux-form 创建一个组件。这是我的组件
import React, { PropTypes } from 'react'
import Input from 'react-toolbox'
export const TextField = ({ input, meta: { touched, error }, ...custom }) => (
<Input
error={touched && error}
{...input}
{...custom}
/>
)
TextField.propTypes = {
input: PropTypes.object,
meta: PropTypes.object
}
export default TextField
我还创建了一个index.js 文件以便轻松导入它
import TextField from './TextField'
export default TextField
那我就这样用
import TextField from 'components/TextField'
import { Field } from 'redux-form'
<form onSubmit={props.handleSubmit(props.loginUser)}>
<Field type='email' label='Email' name='email' component={TextField} required />
</form>
但是我得到了这个错误
错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。检查
TextField的渲染方法。
我又检查了一遍
- the redux form doc
- 其他与 SO 相关的主题,例如 one 或 one
【问题讨论】:
标签: reactjs redux redux-form react-toolbox