Here is my form:
import React from 'react'
import { Form, Button } from 'semantic-ui-react'
const CreatePostForm = ({ onSubmit }) =>
<Form onSubmit={onSubmit}>
<Form.Input name='user' label='user' placeholder='Enter user name' />
<Form.Input name='title' label='title' placeholder='Enter post title' />
<Form.Input name='text' label='text' placeholder='Enter post text' />
<Form.Input name='category' label='category' placeholder='Enter post category' />
<Button type='submit'>Submit</Button>
</Form>
export default CreatePostForm
It is then connected:
import { connect } from 'react-redux'
import CreatePostForm from '../components/CreatePostForm.jsx'
const mapDispatchToProps = (dispatch, props) => {
return {
onSubmit: (e, data) => {
console.log(e)
console.log(data)
},
}
}
const ConnectedCreatePostForm = connect(null, mapDispatchToProps)(CreatePostForm)
export default ConnectedCreatePostForm
In onSubmit I expect some data to be passed that would allow me to retrieve each input form field value by name but I can't access it somehow: there is event and data (I would hope for) which is just the form itself not really data. How to access the values upon submission? I don't want to handle state and want my component - CreatePostForm - to stay dumb.