react-hook-form 7.45.0 → 7.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2030,6 +2030,9 @@ function createFormControl(props = {}, flushRootRender) {
2030
2030
  },
2031
2031
  });
2032
2032
  _names.mount.add(name);
2033
+ if (!isUndefined(options.value)) {
2034
+ set(_formValues, name, options.value);
2035
+ }
2033
2036
  field
2034
2037
  ? disabledIsDefined &&
2035
2038
  set(_formValues, name, options.disabled
@@ -2378,6 +2381,7 @@ function createFormControl(props = {}, flushRootRender) {
2378
2381
  */
2379
2382
  function useForm(props = {}) {
2380
2383
  const _formControl = React.useRef();
2384
+ const _values = React.useRef();
2381
2385
  const [formState, updateFormState] = React.useState({
2382
2386
  isDirty: false,
2383
2387
  isValidating: false,
@@ -2411,10 +2415,9 @@ function useForm(props = {}) {
2411
2415
  },
2412
2416
  });
2413
2417
  React.useEffect(() => {
2414
- if (props.values &&
2415
- (!deepEqual(props.values, control._defaultValues) ||
2416
- !deepEqual(props.values, control._formValues))) {
2418
+ if (props.values && !deepEqual(props.values, _values.current)) {
2417
2419
  control._reset(props.values, control._options.resetOptions);
2420
+ _values.current = props.values;
2418
2421
  }
2419
2422
  else {
2420
2423
  control._resetDefaultValues();