Answer the question
In order to leave comments, you need to log in
Why doesn't redux-form work correctly when there are initialValues?
There is a redux-form form initialized in the container:
ProgramsCreateContainer = reduxForm({
form: 'update-programs',
enableReinitialize: true,
keepDirtyOnReinitialize: true,
onSubmit,
validate,
})(ProgramsCreateContainer)
function select(state) {
const selector = formValueSelector('update-programs')
return {
initialValues: state.programs.program,
}
}
function mapDispatchToProps(dispatch) {
return {
receiveProgram: bindActionCreators(receiveProgram, dispatch),
saveEventId: bindActionCreators(saveEventId, dispatch),
}
}
ProgramsCreateContainer = connect(select, mapDispatchToProps)(ProgramsCreateContainer)
export default ProgramsCreateContainer
<div className="robofinist__h-table-item">
<h3 className="robofinist__h-table-item-name">Описание</h3>
<p className="robofinist__h-table-item-value" style={{ minHeight: '260px' }}>
<RFCKEditorField name="description" />
</p>
</div>
import React, { Component } from 'react'
import { Field } from 'redux-form'
import { WYSIWYGEditor } from '../../ui/molecules'
export class RFCKEditorField extends Component {
constructor(props) {
super(props)
this.generateCKEditorField = this.generateCKEditorField.bind(this)
}
generateCKEditorField({ input, ...field }) {
return (
<div>
<WYSIWYGEditor {...input} />
{field.touched && field.error && <span className="error">{field.error}</span>}
</div>
)
}
render() {
return (
<Field {...this.props} component={(field, meta) => this.generateCKEditorField(field, meta)} />
)
}
}
RFCKEditorField.defaultProps = {};
RFCKEditorField.propTypes = {
onChange: React.PropTypes.func.isRequired,
}
<Field {...this.props} component={(field, meta) => this.generateCKEditorField(field, meta)} />
render() {
return (
<Field {...this.props} component={this.generateCKEditorField} />
)
}
autofill('description', selectedCompetition.content)
Answer the question
In order to leave comments, you need to log in
Unfortunately, I can’t really get into your problem, but when I work with redux-form, I usually do this.props.initialize({...}) method in the componentDidMount of the component, which I connect to the form with the this.props.initialize({...}) method in which I prescribe objects corresponding to the fields by default
componentDidMount (){
this.props.initialize({name : "vasya"})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question