Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,24 +343,6 @@ function Form(props) {
});
});

// We need to verify that all references and values are still actual.
// We should not store it when e.g. some input has been unmounted
_.each(inputRefs.current, (inputRef, inputID) => {
if (inputRef) {
return;
}

delete inputRefs.current[inputID];

setInputValues((prevState) => {
const copyPrevState = _.clone(prevState);

delete copyPrevState[inputID];

return copyPrevState;
});
});

return childrenElements;
},
[errors, inputRefs, inputValues, onValidate, props.draftValues, props.formID, props.formState, setTouchedInput],
Expand Down Expand Up @@ -432,6 +414,29 @@ function Form(props) {
],
);

useEffect(() => {
_.each(inputRefs.current, (inputRef, inputID) => {
if (inputRef) {
return;
}

delete inputRefs.current[inputID];
delete touchedInputs.current[inputID];
delete lastValidatedValues.current[inputID];

setInputValues((prevState) => {
const copyPrevState = _.clone(prevState);

delete copyPrevState[inputID];

return copyPrevState;
});
});
// We need to verify that all references and values are still actual.
// We should not store it when e.g. some input has been unmounted.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [children]);

return (
<SafeAreaConsumer>
{({safeAreaPaddingBottomStyle}) =>
Expand Down