import * as React from 'react' import BootstrapField from './BootstrapField' import { reduxForm, getFormValues, FormProps, FieldArray } from 'redux-form' import { connect } from 'react-redux' import { AppState, Settings, DispatchProps } from './types' interface StateProps { formValues: Settings | undefined, } interface OwnProps extends FormProps { handleSave: (settings: Settings) => void, } interface P extends OwnProps, StateProps, DispatchProps {} // notice that this.props.handleSubmit! and props.form! need a bang "!" when using strictNullChecks // reason is complicated, you can have a look here: https://github.com/erikras/redux-form/pull/1318#issuecomment-231590672 class SettingsForm extends React.PureComponent { render() { // this.props.handleSubmit => redux form's handler // this.props.handleSave => our controller's handler return
Settings
} } // if you need additional stuff from app's state, you totally can connect your form const mapStateToProps = (state: AppState, props: OwnProps): StateProps => ({ formValues: getFormValues(props.form!)(state), }) export default connect(mapStateToProps)(reduxForm({})(SettingsForm))