使用物料ui设置redux表单的初始值赢得';行不通
我想利用我的redux表单来更新一个对象,所以想设置initialValue,我强烈怀疑我做错了什么,但无法找出什么是错的 我在github中关注这个问题,并将初始值作为道具传递使用物料ui设置redux表单的初始值赢得';行不通,redux,material-ui,redux-form,immutable.js,Redux,Material Ui,Redux Form,Immutable.js,我想利用我的redux表单来更新一个对象,所以想设置initialValue,我强烈怀疑我做错了什么,但无法找出什么是错的 我在github中关注这个问题,并将初始值作为道具传递 我的笔记布局是这样的 class NoteLayout extends React.Component { render() { const {handleSubmit, pristine, reset, submitting} = this.props; return ( <div>
我的笔记布局是这样的
class NoteLayout extends React.Component {
render() {
const {handleSubmit, pristine, reset, submitting} = this.props;
return (
<div>
<form onSubmit={handleSubmit}>
<FormSection name="base">
<BaseBar projects={this.props.projects}/>
</FormSection>
<div>
<Field
name="subject"
component={renderTextField}
label="subject"
/>
</div>
<div>
<Field
name="description"
fullWidth={true}
component={renderTextField}
label="description"
/>
</div>
<div>
<RaisedButton
style={style}
fullWidth={false}
primary={true}
type="submit"
disabled={pristine || submitting}>
Submit
</RaisedButton>
<RaisedButton
style={style}
fullWidth={false}
secondary={false}
type="button"
disabled={pristine || submitting}
onClick={reset}>
Clear Values
</RaisedButton>
</div>
</form>
</div>
);
}
}
NoteLayout.propTypes = {
};
export default reduxForm({
form: 'NoteLayout',
validate
})(NoteLayout);
class NoteLayout扩展了React.Component{
render(){
const{handleSubmit,pristine,reset,submiting}=this.props;
返回(
提交
明确的价值观
);
}
}
NoteLayout.propTypes={
};
导出默认reduxForm({
表格:'NoteLayout',
验证
})(注意布局);
答案是redux form/immutable,我可能没有正确查找,immutable关键字帮助了我
我刚才注意到,当传递给connect(Form)时,InitialValue被转换为Map。。
class NoteLayout extends React.Component {
render() {
const {handleSubmit, pristine, reset, submitting} = this.props;
return (
<div>
<form onSubmit={handleSubmit}>
<FormSection name="base">
<BaseBar projects={this.props.projects}/>
</FormSection>
<div>
<Field
name="subject"
component={renderTextField}
label="subject"
/>
</div>
<div>
<Field
name="description"
fullWidth={true}
component={renderTextField}
label="description"
/>
</div>
<div>
<RaisedButton
style={style}
fullWidth={false}
primary={true}
type="submit"
disabled={pristine || submitting}>
Submit
</RaisedButton>
<RaisedButton
style={style}
fullWidth={false}
secondary={false}
type="button"
disabled={pristine || submitting}
onClick={reset}>
Clear Values
</RaisedButton>
</div>
</form>
</div>
);
}
}
NoteLayout.propTypes = {
};
export default reduxForm({
form: 'NoteLayout',
validate
})(NoteLayout);