我正在尝试实现redux-form,但我遇到了一个错误,似乎无法修复它或找到正确的解决方案。错误:React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
import { Form, reduxForm } from 'redux-form';
LocationInput({input, meta: { touched, error }, ...custom}) {
return (
<div>
<input placeholder="Location..." type="text" />
</div>
);
}
render() {
return (
<Form name="locationInput" component={this.LocationInput} />
)
}发布于 2017-02-16 13:58:42
您需要创建一个表单组件并使用redux-form装饰器导出formComponent
export default reduxForm({
form: 'formName' // a unique identifier for this form
})(formComponent)发布于 2017-02-17 01:55:34
您不应该使用Form,除非您正在通过操作分派进行一些花哨的提交。更多地查看示例。
您需要定义一个表单组件,用reduxForm()装饰它,然后在其中放入一些<Field>元素。
https://stackoverflow.com/questions/42264608
复制相似问题