From ad2b72b2991097f1e5f99b30edc15a270cb857d6 Mon Sep 17 00:00:00 2001 From: Simon Kobyda Date: Tue, 17 Oct 2023 13:15:57 +0200 Subject: [PATCH] lib: Fix DynamicListForm's 'Maximum update depth exceeded' flake --- pkg/lib/DynamicListForm.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/lib/DynamicListForm.jsx b/pkg/lib/DynamicListForm.jsx index 4949597504b6..5aedda55f09d 100644 --- a/pkg/lib/DynamicListForm.jsx +++ b/pkg/lib/DynamicListForm.jsx @@ -41,12 +41,12 @@ export class DynamicListForm extends React.Component { } removeItem(idx) { - this.setState(state => { - const validationFailedDelta = this.props.validationFailed ? [...this.props.validationFailed] : []; - // We also need to remove any error messages which the item (row) may have contained - validationFailedDelta.splice(idx, 1); - this.props.onValidationChange?.(validationFailedDelta); + const validationFailedDelta = this.props.validationFailed ? [...this.props.validationFailed] : []; + // We also need to remove any error messages which the item (row) may have contained + validationFailedDelta.splice(idx, 1); + this.props.onValidationChange?.(validationFailedDelta); + this.setState(state => { const items = state.list.concat(); items.splice(idx, 1);