Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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
Reactjs Redux表单-如何使用标志禁用同步/异步验证_Reactjs_React Redux_React Router_Redux Form_React Redux Form - Fatal编程技术网

Reactjs Redux表单-如何使用标志禁用同步/异步验证

Reactjs Redux表单-如何使用标志禁用同步/异步验证,reactjs,react-redux,react-router,redux-form,react-redux-form,Reactjs,React Redux,React Router,Redux Form,React Redux Form,我正在寻找一种最非侵入性的方法,以禁用针对开发/调试目的的redux表单验证 我有一个类似于教程的向导表单,但我使用的是字段验证器和异步验证器 我仍然希望显示错误,但即使验证失败,也可以继续执行下一个向导步骤 我想向url添加一个标志,如?ignore validation=true(使用react路由器) 以下是我的向导步骤1的片段: export class CustomerStep1 extends React.PureComponent<FormProps> { re

我正在寻找一种最非侵入性的方法,以禁用针对开发/调试目的的redux表单验证
我有一个类似于教程的向导表单,但我使用的是字段验证器和异步验证器
我仍然希望显示错误,但即使验证失败,也可以继续执行下一个向导步骤
我想向url添加一个标志,如?ignore validation=true(使用react路由器)

以下是我的向导步骤1的片段:

export class CustomerStep1 extends React.PureComponent<FormProps> {
    render(): React.Node {
            const {
                handleSubmit,
            } = this.props;

            const submit = handleSubmit(createValidateCardAction);

            return (
                    <form onSubmit={submit}>

                                    <Field
                                        name="card_number"
                                        placeholder="7777 1234 5678 9012"
                                        component={Input}
                                        validate={cardNumber}
                                    />
...

export default reduxForm({
    form: 'customerWizard',
    destroyOnUnmount: false,
    forceUnregisterOnUnmount: true,
})(CustomerStep1);
导出类CustomerStep1扩展了React.PureComponent{
render():React.Node{
常数{
手推,
}=这是道具;
const submit=handleSubmit(createValidateCardAction);
返回(
...
导出默认reduxForm({
表单:“customerWizard”,
DestroyOnMont:false,
ForceUnregisterUnmount:true,
})(客户步骤1);

我在这里看到两种可能性:

1) 将向导窗体拆分为多个窗体,并分别进行验证。您可以创建另一个状态来控制要显示的窗体。即使要管理的窗体更多,我也会选择该状态

2) 您可以只保留每个字段的异步验证,并在其中抛出错误。此外,您必须创建一个状态来管理页面,并在异步验证函数中对其进行管理。我创建了第二种方法的示例: