I don't wanna use redux-form, i would like to dispatch all values of the form in the container place. The question is how to get title and content (together) by handleChange function
The container file looks like this:
import { connect } from "react-redux";
import AddPost from "../components/Posts/AddPost";
import { updateNewPost, clearNewPost } from "../actions/new-post";
import { createPost } from "../actions/posts";
const mapStateToProps = ({ title, content, auth }) => {
return { title, content, auth };
};
const mapDispatchToProps = dispatch => {
return {
handleChange(event) {
dispatch(updateNewPost(event.target.value));
},
handleSubmit(event, title, content, uid) {
event.preventDefault();
dispatch(createPost({ title, content, uid }));
dispatch(clearNewPost());
}
};
};
export default connect(mapStateToProps, mapDispatchToProps)(AddPost);
The Component file looks like this:
import React, { PropTypes } from "react";
const AddPost = ({ title, content, auth, handleChange, handleSubmit }) => (
<form onSubmit={event => handleSubmit(event, title, content, auth.uid)}>
<input
type="text"
placeholder="title"
value={title}
onChange={handleChange}
/>
<input
type="text"
placeholder="content"
value={content}
onChange={handleChange}
/>
<input type="submit" value="Post" />
</form>
);
AddPost.propTypes = {
title: PropTypes.string,
content: PropTypes.string,
auth: PropTypes.object,
handleChange: PropTypes.func,
handleSubmit: PropTypes.func
};
export default AddPost;
thank you for help