Answer the question
In order to leave comments, you need to log in
How to make a form title (redux-form) using props?
The page generates many dynamic forms.
form example:
import React, {Component} from 'react'
import Button from '@material-ui/core/Button'
import WysiwygTextarea from 'shared/ui/WysiwygTextarea'
import MaterialInput from 'shared/ui/MaterialInput'
import {reduxForm} from 'redux-form'
render(){
return(
<form onSubmit={this.props.handleSubmit}>
<WysiwygTextarea
change={this.props.change}
name="message"
classes={'wysiwyg__component_chat'}
toolbarClassName="demo-toolbar-absolute"
/>
{this.props.key && <div className="dragon-form__field" style={{display : 'none'}}>
<MaterialInput
name="messageId"
/>
</div>}
<Button type="submit" variant="outlined">Отправить</Button>
</form>
)
}
}
const validate = ({message}) => {
const errors = {}
if (!message) errors.name = 'Введите текст сообщения'
return errors
}
export default reduxForm({
form: 'room', // как вместо 'room' закинуть данные из props ?
validate
})(ChatForm)
Answer the question
In order to leave comments, you need to log in
export default reduxForm({ validate })(ChatForm);
If you want to pass the name as the name property, then you can wrap the component in connect:
const mapStateToProps = (state, ownProps) => ({
form: ownProps.name,
});
export default compose(
connect(mapStateToProps),
reduxForm({ validate }),
)(ChatForm);
<ChatForm name={name} />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question