Eric Stermer
Eric Stermer

Reputation: 1101

Need Help Pinpointing this warning - Warning: setState(...): Cannot update during an existing state transition

I am using redux-form and react-redux.

This is the warning I am getting.

enter image description here

You will notice that is points to 3 places in my code CreateNewOrderForm.jsx:39, NewOrderFormFour.jsx:65, and NewOrderFormFour.jsx:122.

I need another pair eyes to look at it.

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:

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

NewOrderFormFour.jsx:122:

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

Do I need to call the this.openConfirmationDialog method in the handleSubmit?

Or put it in a callback?

Struggled to pinpoint the error since i get over 1000 of them.

What could i change to get this to work?

Upvotes: 1

Views: 67

Answers (1)

Andrii Starusiev
Andrii Starusiev

Reputation: 7764

I think you need to use arrow funcion in submit onSubmit={() => handleSubmit(this.openConfirmationDialog()) }. In your variant you call this function when component rendering.

Upvotes: 2

Related Questions