const AsyncValidationForm = props => {
console.log("AsyncValidationForm ---->");
const { handleSubmit, pristine, reset, submitting } = props;
return (
<form onSubmit={handleSubmit}>
<Field
name="username"
type="text"
component={renderField}
label="Username"
/>
<Field
name="password"
type="password"
component={renderField}
label="Password"
/>
<div>
<button type="submit" disabled={submitting}>
Sign Up
</button>
<button type="button" disabled={pristine || submitting} onClick={reset}>
Clear Values
</button>
</div>
</form>
);
};
答案 0 :(得分:1)
1)
您必须将onSubmit参数传递给具有de reduxForm HOC的组件:
<AsyncValidationForm onSubmit={values => { console.log(values) }} />
2) 您没有正确创建商店,因为商店需要像示例一样的表单字段:
import { reducer as reduxFormReducer } from 'redux-form';
const reducer = combineReducers({
form: reduxFormReducer, // mounted under "form"
});
但是您要定义商店如下:
const reducer = () => ({});
const store = createStore(reducer);
您可以简单地从index.js中的store.js文件导入商店:
import store from './store';