From 9534b2a85609f29bd56433ac53e8121670884ec5 Mon Sep 17 00:00:00 2001 From: Marina Chirchikova Date: Tue, 26 Feb 2019 10:56:32 -0500 Subject: [PATCH] Fix Form-State List regression Introduced in this commit: https://github.com/Shopify/quilt/pull/475/files#diff-68157ac38fbcaa003b546774b1857293R48 on line 48. The bug is that initialValue[index][fieldPath] throws an exception instead of returning undefined the way it previously did when initialValue[index] is undefined. I added an extra check to see if initialValue.index is defined and return undefined if its not. --- packages/react-form-state/src/components/List.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-form-state/src/components/List.tsx b/packages/react-form-state/src/components/List.tsx index a20262b652..9b2033e331 100644 --- a/packages/react-form-state/src/components/List.tsx +++ b/packages/react-form-state/src/components/List.tsx @@ -45,7 +45,8 @@ export default class List extends React.Component< const innerFields: FieldDescriptors = mapObject( fieldValues, (value, fieldPath) => { - const initialFieldValue = initialValue[index][fieldPath]; + const initialFieldValue = + initialValue[index] && initialValue[index][fieldPath]; return { value, onBlur,