From acfa0b8d060b84b227f36d2f079961ea6e732b8a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 10 Sep 2020 22:22:16 +0200 Subject: [PATCH] refactor to use optional chain expressions --- src/components/atoms/Input/index.tsx | 5 +- src/components/atoms/Price/index.tsx | 4 +- src/components/atoms/Table/index.tsx | 2 +- src/components/atoms/Tags.tsx | 7 ++- .../molecules/FormFields/Price/Dynamic.tsx | 2 +- src/components/molecules/Menu.tsx | 2 +- .../organisms/AssetContent/MetaSecondary.tsx | 46 +++++++++---------- .../organisms/AssetContent/index.tsx | 19 ++++---- src/components/organisms/AssetList.tsx | 2 +- src/components/pages/Publish/Preview.tsx | 26 +++++------ src/providers/UserPreferences.tsx | 6 +-- tests/unit/components/Button.test.tsx | 4 +- 12 files changed, 58 insertions(+), 67 deletions(-) diff --git a/src/components/atoms/Input/index.tsx b/src/components/atoms/Input/index.tsx index 3d6b36f74..7ff57eb36 100644 --- a/src/components/atoms/Input/index.tsx +++ b/src/components/atoms/Input/index.tsx @@ -53,8 +53,7 @@ export default function Input(props: Partial): ReactElement { } = props const hasError = - props.form && - props.form.touched[field.name] && + props.form?.touched[field.name] && typeof props.form.errors[field.name] === 'string' const styleClasses = cx({ @@ -65,7 +64,7 @@ export default function Input(props: Partial): ReactElement { return (