Skip to content

Commit

Permalink
added optional chaining operator to resolve code break issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Apple authored and Apple committed Jun 5, 2023
1 parent 0a817c1 commit eab4691
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const MultiAutocompleteSelectFieldComponent: React.FC<MultiAutocompleteSelectFie
if (fetchOnFocus) {
fetchChoices(inputValue);
}
input.current.select();
input?.current?.select();
};

const handleToggleMenu = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
);

const [selectedTaxType, setSelectedTaxType] = useStateFromProps(
product?.taxType.description,
product?.taxType?.description,
);

const categories = getChoices(categoryChoiceList);
Expand Down
8 changes: 4 additions & 4 deletions src/products/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ export function getProductUpdatePageFormData(

return {
category: maybe(() => product.category.id, ""),
changeTaxCode: !!product?.taxType.taxCode,
chargeTaxes: maybe(() => product.chargeTaxes, false),
changeTaxCode: !!product?.taxType?.taxCode,
chargeTaxes: maybe(() => product?.chargeTaxes, false),
collections: maybe(
() => product.collections.map(collection => collection.id),
() => product?.collections?.map(collection => collection.id),
[],
),
isAvailable: !!product?.isAvailable,
Expand All @@ -224,7 +224,7 @@ export function getProductUpdatePageFormData(
"",
),
slug: product?.slug || "",
taxCode: product?.taxType.taxCode,
taxCode: product?.taxType?.taxCode,
trackInventory: !!variant?.trackInventory,
weight: product?.weight?.value.toString() || "",
isPreorder: !!variant?.preorder || false,
Expand Down

0 comments on commit eab4691

Please sign in to comment.