What I've been trying is t get a value from formReducer
in a container component.
There are two component. One is a presentational component with Redux-Form
.
class Form extends React.Component {
render() {
return (
<div>
<form onSubmit={handleSubmit}>
<Field name="title"
component="input"
type="text"/>
</form>
</div>
)
}
}
Form = reduxForm({
form: 'PostEditor',
enableReinitialize: true,
})(Form);
Form = connect(
state => ({
initialValues: state.post.post,
enableReinitialize: true,
}),
)(Form)
export default Form;
And the other is its container, which is where I'd like to access formReducer
.
class PostEditor extends React.Component {
render() {
console.log("form", this.props.PostEditor);//This results in "undefined"
return (<Form onSubmit={data=> this.handleSubmit(data)}/>);
}
}
const mapStateToProps = (state) => {
return {
PostEditor: state.form
}
}
export default connect(mapStateToProps, null)(PostEditor);
In Redux' store, form reducer is set to be state.form
, but this cannot be accessed.
Is it possible to get values from the reducer?