Build inputSourcesMap using an array reduce method instead of forEach with a local variable.

This commit is contained in:
mabashian
2020-06-01 15:55:18 -04:00
parent 5367bc4d3b
commit 78ade1d99d

View File

@@ -37,11 +37,12 @@ function CredentialEdit({ credential, me }) {
CredentialsAPI.readInputSources(credential.id, { page_size: 200 }), CredentialsAPI.readInputSources(credential.id, { page_size: 200 }),
]); ]);
setCredentialTypes(loadedCredentialTypes); setCredentialTypes(loadedCredentialTypes);
const inputSourcesMap = {}; setInputSources(
loadedInputSources.forEach(inputSource => { loadedInputSources.reduce((inputSourcesMap, inputSource) => {
inputSourcesMap[inputSource.input_field_name] = inputSource; inputSourcesMap[inputSource.input_field_name] = inputSource;
}); return inputSourcesMap;
setInputSources(inputSourcesMap); }, {})
);
} catch (err) { } catch (err) {
setError(err); setError(err);
} finally { } finally {