简体   繁体   English

需要帮助查明此警告-警告:setState(…):在现有状态转换期间无法更新

[英]Need Help Pinpointing this warning - Warning: setState(…): Cannot update during an existing state transition

I am using redux-form and react-redux. 我正在使用redux-form和react-redux。

This is the warning I am getting. 这是我得到的警告。

在此处输入图片说明

You will notice that is points to 3 places in my code CreateNewOrderForm.jsx:39, NewOrderFormFour.jsx:65, and NewOrderFormFour.jsx:122. 您会注意到,这指向我的代码CreateNewOrderForm.jsx:39,NewOrderFormFour.jsx:65和NewOrderFormFour.jsx:122中的3个位置。

I need another pair eyes to look at it. 我需要另一双眼睛看它。

CreateNewOrderForm.jsx:39: CreateNewOrderForm.jsx:39:

toggleDialog = (id) => {
    const { dialog, openDialogFunction, closeDialogFunction } = this.props;
    if (dialog.show && (dialog.id === 'confirmOrderDialog' || 'confirmOrderDialog')) {
      closeDialogFunction(id);
    }
    else {
      openDialogFunction(id, 1);
    }
  }

NewOrderFormFour.jsx:65: NewOrderFormFour.jsx:65:

openConfirmationDialog = () => {
  const { openDialogFunction } = this.props;
  openDialogFunction('confirmOrderDialog');
}

NewOrderFormFour.jsx:122: NewOrderFormFour.jsx:122:

<Form
 id="createOrder"
 onSubmit={ handleSubmit(this.openConfirmationDialog()) }
>

Do I need to call the this.openConfirmationDialog method in the handleSubmit? 我是否需要在this.openConfirmationDialog中调用this.openConfirmationDialog方法?

Or put it in a callback? 还是放在回调中?

Struggled to pinpoint the error since i get over 1000 of them. 努力找出错误,因为我获得了1000多个错误。

What could i change to get this to work? 我要改变什么才能使其正常工作?

I think you need to use arrow funcion in submit onSubmit={() => handleSubmit(this.openConfirmationDialog()) } . 我认为您需要在onSubmit={() => handleSubmit(this.openConfirmationDialog()) }使用箭头功能。 In your variant you call this function when component rendering. 在您的变体中,在渲染组件时调用此函数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ReactJS:警告:setState(…):在现有状态转换期间无法更新 - ReactJS: Warning: setState(…): Cannot update during an existing state transition 警告:setState(...):在现有状态转换期间无法更新 - Warning: setState(…): Cannot update during an existing state transition 警告:setState(...):无法在react redux中的现有状态转换期间更新 - Warning: setState(…): Cannot update during an existing state transition in react redux 反应:警告:setState(…):在现有状态转换期间无法更新 - React: Warning: setState(…): Cannot update during an existing state transition 警告:setState(...):在使用redux / immutable的现有状态转换期间无法更新 - Warning: setState(…): Cannot update during an existing state transition with redux/immutable 警告:setState(…):在现有状态转换期间无法更新 - Warning: setState(…): Cannot update during an existing state transition ES6 - 警告:setState(...):在现有状态转换期间无法更新 - ES6 - Warning: setState(…): Cannot update during an existing state transition 警告:在现有状态转换期间无法更新 - Warning: Cannot update during an existing state transition 反应:警告setState无法在现有状态转换(例如在渲染内)期间更新 - React: Warning setState Cannot update during an existing state transition (such as within a render) 知道是什么原因引起的“警告:setState(...):在现有状态转换过程中无法更新...”,但不确定将原因移至何处 - Know what is causing “Warning: setState(…): Cannot update during an existing state transition…”, but not sure where the cause should be moved to
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM