Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Formik在ReactJS中实现单选按钮_Reactjs_Radio Button_Formik_Yup - Fatal编程技术网

如何使用Formik在ReactJS中实现单选按钮

如何使用Formik在ReactJS中实现单选按钮,reactjs,radio-button,formik,yup,Reactjs,Radio Button,Formik,Yup,在我的注册表表单中,我的单选按钮不起作用,当我按下create按钮时,什么都没有发生,它不会激活onSubmit函数,但是如果我删除它们,它就会被激活 这是我的密码: 从“React”导入React; 从“Formik”导入{Formik,Field,Form,ErrorMessage}; 从“Yup”导入*作为Yup; 常量男性=道具=>( ); const女性=道具=>( ); 导出类注册表扩展了React.Component{ render(){ 设{initialValues}=this

在我的注册表表单中,我的单选按钮不起作用,当我按下create按钮时,什么都没有发生,它不会激活onSubmit函数,但是如果我删除它们,它就会被激活

这是我的密码:

从“React”导入React;
从“Formik”导入{Formik,Field,Form,ErrorMessage};
从“Yup”导入*作为Yup;
常量男性=道具=>(
);
const女性=道具=>(
);
导出类注册表扩展了React.Component{
render(){
设{initialValues}=this.state;
返回(
注册
{
setStatus();
authenticationservice.newuser({email,password,gender})。然后(
用户=>{
const{from}=this.props.location.state | |{from:{pathname:“/”}``
这个。道具。历史。推(从);
},
错误=>{
设置提交(假);
设置状态(错误);
}
);
}}
render={({错误,状态,触摸,isSubmitting})=>(
电子邮件地址
性别
男性
女性
创造
{isSubmitting&&}
{status&&{status}
)}
/>
);
}
}

我不确定会发生什么,因为我没有得到任何错误代码,只是没有发生任何事情

它确实调用了onSubmit一次,下面是代码沙盒示例。这似乎不起作用。它只调用onSubmit一次,下面是代码沙盒示例。这似乎不起作用