使用redux,我创建了一个表单,并且能够分派操作,验证,并且工作正常,没有任何问题。但是将数据加载/初始化到表单字段(ReduxForm)上不会填充数据而是执行了代码,有人可以帮助我解决问题或哪里出错了,代码可以很好地执行但数据没有填充到相应的表单字段上
import "../../views/CSS/Organization.css";
import { Container, Row, Col } from "react-bootstrap";
import {createOrganization} from "../../store/actions/org_actions"
import {connect} from "react-redux"
import moment from 'moment'
import {Field, reduxForm} from 'redux-form'
class Organization extends Component {
componentDidMount(){
}
renderInputField = (field)=>(
<div class='form-group' >
<div class='oddT-icon-input' >
<input {...field.input} placeholder={`${field.placeHolder}`} class='oddT-text' />
<i class={`${field.icon}`}></i>
</div>
<div class="validation-error">{field.meta.touched?field.meta.error:""}</div>
</div>
)
render() {
return (
<div>
<Row>
<div class='col-sm-6' >
<label htmlFor="fePassword">Organization Name</label>
<Field
name="orgName"
component={this.renderInputField}
placeHolder="Organization Name"
icon="fa fa-user"
/>
</div>
</Row>
);
}
}
function mapStateToProps(state,props){
console.log(state)
return {
success: {orgName:"ARSCCOM"},
initialValues :{orgName:"ARSCCOM"}
}
}
export default reduxForm({
validate,
form: 'Organization',
enableReinitialize : true
})(connect(mapStateToProps,{createOrganization})(Organization))
非常感谢