ClonesTable: Ensure source exists before reading its account_id property

If a clone is created using a source, and the source is then deleted,
the source will be undefined. Attempting to read the account_id from
undefined causes the app to crash. Optional chaining fixes this.
This commit is contained in:
lucasgarfield 2023-03-08 10:30:53 +01:00 committed by Lucas Garfield
parent b729edf152
commit f0ae99b31e

View file

@ -31,7 +31,7 @@ const Row = ({ imageId }) => {
if (isSuccess) {
const accountId = awsSources.find(
(source) => source.id === image.share_with_sources[0]
).account_id;
)?.account_id;
return accountId;
}
return null;