From 39fc91c820a2a6f5b45fa54ba86d2580a28e13fd Mon Sep 17 00:00:00 2001 From: Pierre Huyghe Date: Fri, 25 Feb 2022 16:18:22 +0100 Subject: [PATCH] fix(libs/form-context): make selectors safer (#61) --- libs/form-context/src/lib/forms.selectors.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/form-context/src/lib/forms.selectors.ts b/libs/form-context/src/lib/forms.selectors.ts index 0ea5708..cccbd61 100644 --- a/libs/form-context/src/lib/forms.selectors.ts +++ b/libs/form-context/src/lib/forms.selectors.ts @@ -6,10 +6,10 @@ const defaultData = {} as FieldValues; export const getFormData = (formId: string) => (state: DefaultFormState) => state?.[formId]?.data || defaultData; export const getCurrentStepIndex = (formId: string) => (state: DefaultFormState) => - state?.[formId].currentStepIndex || 0; + state?.[formId]?.currentStepIndex || 0; export const isLastStep = (formId: string) => (state: DefaultFormState) => { - const value = state[formId]?.isLastStep; + const value = state?.[formId]?.isLastStep; if (typeof value === 'boolean') { return value; }