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
6 changes: 3 additions & 3 deletions src/useField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@

// Only update if the new initialValue differs from current form initial
if (!isEqual(initialValue, currentFormInitial)) {
const currentValue = getIn(formState.values, name);
const currentValue = formState.values ? getIn(formState.values, name) : undefined;

// If the current value matches the new initial value, update the form's
// initialValues to reflect this. This is needed for radio buttons where
Expand Down Expand Up @@ -263,7 +263,7 @@
}
}
}
}, [initialValue, name, form]);

Check warning on line 266 in src/useField.ts

View workflow job for this annotation

GitHub Actions / Lint

React Hook React.useEffect has a missing dependency: 'configRef'. Either include it or remove the dependency array

const meta: any = {};
addLazyFieldMetaState(meta, state);
Expand All @@ -271,7 +271,7 @@
// Fix #869: If name changed but state hasn't updated yet (effect hasn't run),
// get the value directly from form values to avoid returning stale value
let value = state.name !== name
? getIn(form.getState().values, name)
? getIn(form.getState().values ?? {}, name)
: state.value;

// Handle null values first
Expand Down Expand Up @@ -308,7 +308,7 @@
const getInputChecked = () => {
// Fix #869: Same as getInputValue - sync with current name
let value = state.name !== name
? getIn(form.getState().values, name)
? getIn(form.getState().values ?? {}, name)
: state.value;
if (type === "checkbox") {
value = parse(value, name);
Expand Down
Loading