Forms Redux表单值属性未定义&;提交时更新

Forms Redux表单值属性未定义&;提交时更新,forms,reactjs,react-router,submit,redux-form,Forms,Reactjs,React Router,Submit,Redux Form,我使用redux表单是为了在React Web App中提交新的用户注册页面,但当我尝试获取参数值表单上的输入字段值时,它在mapDispatchToProps中返回时未定义。我读过很多帖子,有人声称他们的值变量没有定义,但我不是这样。只有当我console.log(值。[inputName])时,我才得到未定义。根据文件,我不能说我做了任何错误的事情 请有人帮助确定是什么原因导致值。电子邮件未定义?谢谢 // presentational component class Signup exte

我使用redux表单是为了在React Web App中提交新的用户注册页面,但当我尝试获取参数
表单上的输入字段值时,它在
mapDispatchToProps
中返回时未定义。我读过很多帖子,有人声称他们的
变量没有定义,但我不是这样。只有当我
console.log(值。[inputName])
时,我才得到未定义。根据文件,我不能说我做了任何错误的事情

请有人帮助确定是什么原因导致
值。电子邮件
未定义?谢谢

// presentational component
class Signup extends Component {
    render() {
        const { handleSubmit } = this.props;
        return (
            <div>
                <h1>Signup</h1>
                <form onSubmit={handleSubmit}>
                    <div>   
                        <label>
                            Email: 
                            <Field component="input" type="email" name="email" />
                        </label>
                    </div>
                    <div>   
                        <label>
                            Password: 
                            <Field component="input" type="password" name="password" />
                        </label>
                    </div>
                    <button type="submit" >Submit</button>
                </form>
            </div>
        )
    }
}

export default reduxForm({
    form: 'Signup',
    enableReinitialize: true
})(Signup)

// redux container component
const mapDispatchToProps = (dispatch) => {
    return {
        handleSubmit: (values) => {
            console.log(values.email); // outputs undefined!
        }
    };
}

const SignupContainer = connect(
    null,
    mapDispatchToProps
)(Signup)

export default SignupContainer;


// reducer index.js
import { reducer as formReducer } from 'redux-form';

export const appReducer = combineReducers({
    form: formReducer
})


// store.js
export const store = createStore(
    appReducer,
    applyMiddleware(
        thunkMiddleware,
        loggerMiddleware
    )
);
//表示组件
类注册扩展了组件{
render(){
const{handleSubmit}=this.props;
返回(
报名
电邮:
密码:
提交
)
}
}
导出默认reduxForm({
表格:'注册',
启用重新初始化:true
})(报名)
//redux容器组件
const mapDispatchToProps=(调度)=>{
返回{
handleSubmit:(值)=>{
console.log(values.email);//输出未定义!
}
};
}
const SignupContainer=connect(
无效的
mapDispatchToProps
)(报名)
导出默认注册容器;
//减速器索引.js
从'redux form'导入{reducer as formReducer};
export const appReducer=组合减速机({
形态:形态还原剂
})
//store.js
export const store=createStore(
评论员,
applyMiddleware(
Thunk,
日志软件
)
);
旁注 我注意到,每当我第一次单击表单上的submit按钮时,页面就会刷新(因此我看不到console.log)。所有正在进行的时间不会导致刷新,但我不确定原因。对此的任何解释都将不胜感激


更新
将我的路由器从HashHistory更改为BrowserRouter(react Router)后,每次单击submit时,页面都会刷新。似乎我现在有两个问题。

您的表单中有两个密码字段,没有电子邮件字段……啊,很抱歉。这是由于复制/粘贴错误造成的打字错误,但我的实际代码有一个单独的电子邮件和密码字段。我已经更新了我的帖子,以显示更准确的代码。