Skip to content

Commit b2d58aa

Browse files
committed
networkDesign frontend: fix update loop in simulation edit
The `csvFieldMapper` prop should not be in the dependency list of the upload status update, otherwise it loops. If the mapper changed, the parent is already aware, this effect just needs to listen for upload status updates.
1 parent c3e8bd9 commit b2d58aa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/transition-frontend/src/components/forms/csv/GenericCsvImportAndMappingForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const GenericCsvImportAndMappingForm: React.FunctionComponent<GenericCsvImportAn
118118
// Just uploaded, no need to upload it again
119119
setReadyToUpload(false);
120120
}
121-
}, [uploadStatus.status, props.csvFieldMapper]);
121+
}, [uploadStatus.status]); // csvFieldMapper should not be a dependency, even if used in the function, otherwise it loops. This effect just listens to the upload status update
122122

123123
const csvFileFields = props.csvFieldMapper.getCsvFields();
124124

packages/transition-frontend/src/components/forms/networkDesign/widgets/OptionsDescriptorWidgets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const OptionsEditComponent: React.FunctionComponent<OptionsEditComponentProps<an
203203
props: OptionsEditComponentProps<any>
204204
) => {
205205
const { t } = useTranslation(['transit', 'main']);
206-
const options = props.optionsDescriptor.getOptions();
206+
const options = React.useMemo(() => props.optionsDescriptor.getOptions(), [props.optionsDescriptor]);
207207
const optionWidgets = Object.keys(options).map((optionName) => {
208208
const option = options[optionName];
209209
return (

0 commit comments

Comments
 (0)