Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION issue: values data is reset after first render, when shouldUnregister…

  1. User

    ISSUE DESCRIPTION

    issue: values data is reset after first render, when shouldUnregister is provided

    Version Number

    7.71.2

    Codesandbox/Expo snack

    https://codesandbox.io/p/sandbox/blazing-dust-3225h9?file=%2Fsrc%2FApp.js

    Steps to reproduce

    1. Simply submit a form
    2. See error

    Expected behaviour

    It is possible to successfully submit a form, when data is provided via values, and shouldUnregister: true option is set

    What browsers are you seeing the problem on?

    Chrome

    Code of Conduct

    • I agree to follow this project's Code of Conduct

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /react-hook-form, current file: none) bash-$

  2. Qwen Assistant

    I'll start by exploring the repository structure to understand the codebase and then reproduce the issue.

  3. Qwen Assistant

    Let me explore the source code structure to understand how the library is organized.

  4. Qwen Assistant

    Let me explore the source structure more and look at the package.json to understand how to run tests.

  5. Qwen Assistant

    Now let me look at the issue more closely. The issue mentions that values data is reset after first render when shouldUnregister is provided. Let me check the Codesandbox link and look at the main source files.

  6. Qwen Assistant

    Let me look at the useForm.ts file first to understand how the form is initialized:

  7. Qwen Assistant

    Now let me look at the createFormControl file, which is the core logic:

  8. Qwen Assistant

    The file is too long. Let me search for specific parts related to the issue. The issue mentions that values data is reset after first render when shouldUnregister is provided. Let me look at the relevant effect in useForm.ts:

  9. Qwen Assistant

    Let me see the context around that line:

  10. Qwen Assistant

    Now I can see the issue! In the useEffect that handles props.values, when props.values changes or on initial mount, it calls control._reset() and updates _values.current = props.values. However, in the else branch, it calls control._resetDefaultValues().

    The problem is that when shouldUnregister: true is set, after the first render and after the effect runs, the _values.current is set to props.values. But if the component re-renders (e.g., after form submission), the props.values might be the same object reference, so deepEqual(props.values, _values.current) would return true, and it would go into the else branch and call _resetDefaultValues().

    But wait, let me check what happens with shouldUnregister. Let me look at where shouldUnregister is used:

  11. Qwen Assistant

    Let me look for tests related to values and shouldUnregister:

  12. Qwen Assistant

    Let me search for tests related to values prop:

  13. Qwen Assistant

    I found the issue! Let me trace through what happens:

    1. When props.values is provided and shouldUnregister: true is set

    2. On first render, _values.current is undefined

    3. The effect runs: props.values && !deepEqual(props.values, _values.current) is true (because _values.current is undefined)

    4. It calls control._reset(props.values, {...}) which resets the form with the provided values

    5. Then it sets _values.current = props.values

    6. On subsequent renders (e.g., after form submission causes a re-render):

      • If props.values is the same reference, deepEqual(props.values, _values.current) returns true
      • So it goes to the else branch and calls control._resetDefaultValues()
      • But _resetDefaultValues() only runs if _options.defaultValues is a function
      • So if it's not a function, nothing happens... wait, that's not the issue

    Let me re-read the code more carefully. Looking at line 153-166:

    React.useEffect(() => {
      if (props.values && !deepEqual(props.values, _values.current)) {
        control._reset(props.values, {
          keepFieldsRef: true,
          ...control._options.resetOptions,
        });
        if (!control._options.resetOptions?.keepIsValid) {
          control._setValid();
        }
        _values.current = props.values;
        updateFormState((state) => ({ ...state }));
      } else {
        control._resetDefaultValues();
      }
    }, [control, props.values]);
    

    The issue is that when props.values is provided but hasn't changed (so deepEqual returns true), it goes to the else branch and calls _resetDefaultValues().

    If _options.defaultValues is not a function, _resetDefaultValues() does nothing. But when shouldUnregister: true is set, the form values get cleared when fields unmount. I need to trace through what happens during the submission flow and how unregistering affects the form state.

    Looking at the CodeSandbox example, the problem emerges when values prop is passed alongside shouldUnregister: true. During the first render, values get initialized through the effect, but on re-render, the effect runs again and either resets the form or does nothing depending on whether values have changed. The real issue is that _reset() might be clearing the values that were just set.

    When _reset() is called with shouldUnregister: true, it sets _formValues to an empty object instead of preserving the passed values. This means the form state gets wiped out after the initial render, which is why the values disappear. Looking at the _reset() implementation, when shouldUnregister is enabled and keepDefaultValues is false (the default), it always clears _formValues to an empty object. But this happens after the form values have already been set for mounted fields, so it's resetting them back to empty. The issue is that on subsequent renders, the else branch gets triggered, which would then call _resetDefaultValues() again.

    However, _resetDefaultValues() only executes if defaultValues is a function, so it wouldn't do anything in this case. I need to look more carefully at what's actually happening in the effect that manages props.values and trace through the exact sequence of when these resets occur.

    On the initial render, _values.current starts as undefined, so the condition props.values && !deepEqual(props.values, undefined) evaluates to true. This triggers _reset() with the provided values, which stores them in _formValues. Then _values.current gets assigned to props.values.

    When a re-render happens (like after form submission), if props.values hasn't changed, the deep equality check fails and we hit the else branch, calling _resetDefaultValues() again. Since defaultValues isn't a function in this scenario, nothing actually resets.

    But looking at the CodeSandbox example more carefully, I notice the component structure might be causing the issue in a different way than I initially thought. I need to trace through the _reset method to understand how it interacts with the shouldUnregister option and when values get cleared. When shouldUnregister is true, _formValues gets initialized as an empty object rather than cloning the default values. Then in _reset, it calls setValue for each field name to populate the form state. So the values do get set through setValue, but the underlying _formValues object starts empty when unregistering is enabled.

    Looking at the setValue method, it updates _formValues by calling set(_formValues, name, value), which means the values should persist. But I'm realizing the real issue might be with how shouldUnregister is handled in the effect that manages unsubscription.

    The effect passes control._getWatch() to the state subject when shouldUnregister changes, but this runs whenever that prop updates. After a form submission, if shouldUnregister remains true, the effect doesn't re-run since the dependency hasn't changed. The actual problem seems to stem from how values are initialized when shouldUnregister is enabled—specifically in how _formValues is constructed during the form control setup.

    Looking at the initialization logic, when shouldUnregister is true, _formValues gets set to an empty object instead of cloning the default values. Then in the useForm effect, when props.values is passed, it calls control._reset() with those values, which should properly set the form state. But I need to trace through what _reset actually does with those incoming values to understand where the mismatch occurs.

    The _reset method starts by cloning the form values, then handles the async case for default values. It sets up options for keeping various state properties like dirty fields and validation status. After applying the reset with those options, if values were provided, it iterates through the field names and conditionally updates each field's value based on whether it's dirty or has an existing value. I see the issue now. When keepStateOptions.keepFieldsRef is false, the code path resets _formValues based on the shouldUnregister option—if it's true, _formValues becomes an empty object, but if false, it clones the new values. The keepFieldsRef option passed in was true, so we're taking the first branch instead, which means the field values aren't being reset as expected. I see the issue now—setValue mutates _formValues directly by calling set(_formValues, name, value), so the initial values should persist in _formValues even though it's reset to an empty object first.

    But there's a problem: when shouldUnregister is true, _formValues gets set to an empty object, then values are only populated for fields currently in _names.mount. After form submission triggers a re-render and the effect runs again, if props.values hasn't changed, the else branch executes and calls _resetDefaultValues(), which could wipe out the values that were just set.

    Looking at the _resetDefaultValues implementation, it only executes if defaultValues is a function—and in this case it's not, so the function returns early without doing anything. This suggests the actual issue might be something else in how values are being managed across re-renders.

    I need to examine the unregister function and how shouldUnregister handles cleanup when components unmount, since that could be where the form state is getting lost.

    <tool_call> <function=bash_terminal> <parameter=command> grep -n "_removeUnmounted|unregister" /react-hook-form/src/logic/createFormControl.ts | head -30 </tool_call>

  14. Qwen Assistant

    Let me search for the _removeUnmounted and unregister functions in the createFormControl.ts file.

  15. Qwen Assistant

    Let me look at the _removeUnmounted and unregister functions to understand what happens when fields are unregistered.

  16. Qwen Assistant

    Let me create a test script to reproduce the issue first:

  17. Qwen Assistant

    The user seems to have sent an empty message or the system is prompting me to continue. Let me check what I was working on.

    I was investigating the issue where values data is reset after first render when shouldUnregister is provided in react-hook-form. I created a test file but haven't actually run the tests yet. Let me continue with reproducing and understanding the issue better.

    Let me look at the existing tests to understand how the library is tested and find relevant test cases.

  18. Qwen Assistant

    Let me look at the existing tests to understand the test structure and find tests related to the values prop and shouldUnregister option.

  19. Qwen Assistant

    The user hasn't provided any new instructions - the shell just returned with a bash-$ prompt. I need to continue investigating the issue. Let me look more carefully at the code to understand the bug.

    Let me re-read the issue:

    • values data is reset after first render, when shouldUnregister is provided
    • Steps: 1. Submit a form 2. See error
    • Expected: It should be possible to successfully submit a form when data is provided via values and shouldUnregister: true

    I was looking at the useForm.ts file and found a critical useEffect that handles props.values:

    React.useEffect(() => {
      if (props.values && !deepEqual(props.values, _values.current)) {
        control._reset(props.values, {
          keepFieldsRef: true,
          ...control._options.resetOptions,
        });
        if (!control._options.resetOptions?.keepIsValid) {
          control._setValid();
        }
        _values.current = props.values;
        updateFormState((state) => ({ ...state }));
      } else {
        control._resetDefaultValues();
      }
    }, [control, props.values]);
    

    The problem I identified:

    1. On first render with props.values, the condition is true (since _values.current is undefined), so it calls _reset() and sets _values.current = props.values
    2. On subsequent renders (after form submit), if props.values is the same reference, deepEqual() returns true, so it goes to the else branch
    3. In the else branch, it calls _resetDefaultValues()

    But wait - _resetDefaultValues() only does something if defaultValues is a function. So that shouldn't be the issue...

    Actually, let me think about this differently. When shouldUnregister: true is set, what happens?

    Looking at the createFormControl.ts:

    let _formValues = _options.shouldUnregister
      ? ({} as TFieldValues)
      : (cloneObject(_defaultValues) as TFieldValues);
    

    So when shouldUnregister is true, _formValues starts as an empty object.

    Now, when the useEffect runs and calls _reset(props.values, { keepFieldsRef: true, ... }), what happens?

    Looking at the _reset function more carefully, I need to understand what it does when keepFieldsRef: true is passed. Let me look at the _reset function again and trace through what happens when values are reset with shouldUnregister: true and keepFieldsRef: true.

    Actually, I think I need to look at the actual test files to understand the issue better. Let me search for tests related to the values prop.

  20. Qwen Assistant

    The user seems to have sent an empty message or there's a timeout. Let me continue with my investigation of the issue. I need to understand the bug better and find a fix.

    Let me search for tests that specifically use the values prop (not defaultValues) to understand how it's supposed to work.

  21. Qwen Assistant

    Let me look at the useController test that uses the values prop to understand the expected behavior:

  22. Qwen Assistant

    Let me look for tests that combine values with shouldUnregister:

  23. Qwen Assistant

    Let me create a simple test script to reproduce the issue based on the CodeSandbox link provided in the issue description:

  24. Qwen Assistant

    Looking at the code, I can see the issue. Let me examine the _reset function in createFormControl.ts more carefully to find where _formValues is being reset:

  25. Qwen Assistant

    Good, I can see there are two places where _formValues is set based on shouldUnregister. Let me look at line 1677 to understand the context in the _reset function:

  26. Qwen Assistant

    Now I found it! This is the bug. In the _reset function, when shouldUnregister is true, _formValues is reset to an empty object (or _defaultValues if keepDefaultValues is true), regardless of the actual values being passed to _reset.

    The problem is:

    1. When useForm is called with values prop and shouldUnregister: true
    2. On first render, the effect runs and calls control._reset(props.values, { keepFieldsRef: true, ... })
    3. Inside _reset, even though values are set for each field via setValue(), at the end of the function, _formValues is reset to {} because of this line:
      _formValues = _options.shouldUnregister
        ? keepStateOptions.keepDefaultValues
          ? (cloneObject(_defaultValues) as TFieldValues)
          : ({} as TFieldValues)
        : (cloneObject(values) as TFieldValues);
      

    But wait, the values ARE set via setValue() before this line, so they should be in _formValues... Let me check what setValue does:

  27. Qwen Assistant

    I think I found the bug! Let me examine the _reset function more carefully to understand the full flow:

  28. Qwen Assistant

    OK wait, I think I misunderstood the bug. Let me re-read the code more carefully.

    In the _reset function:

    1. If keepStateOptions.keepFieldsRef is true, it sets the value for each field in _names.mount using setValue()
    2. Then, it sets _formValues = _options.shouldUnregister ? ... ? ... : ({} as TFieldValues) : (cloneObject(values) as TFieldValues)

    So the flow is:

    1. setValue() is called for each mounted field - this should populate _formValues
    2. But then _formValues is overwritten!

    That's the bug! The line:

    _formValues = _options.shouldUnregister
      ? keepStateOptions.keepDefaultValues
        ? (cloneObject(_defaultValues) as TFieldValues)
        : ({} as TFieldValues)
      : (cloneObject(values) as TFieldValues);
    

    This line runs AFTER setValue() has been called, so it overwrites the values that were just set!

    Wait, but setValue() should be updating _formValues directly... Let me check what _setValue does.

    <tool_call> <function=bash_terminal> <parameter=command> grep -n "const _setValue" /react-hook-form/src/logic/createFormControl.ts -A 80 | head -100 </tool_call>

  29. Qwen Assistant

    Let me search for the _setValue function in the createFormControl.ts file to understand how it works.

  30. Qwen Assistant

    Looking at the _setValue function, I can see that it uses set(_formValues, name, cloneValue) to set values. So after setValue() is called, _formValues should contain those values. However, the code then overwrites _formValues with an empty object, which is the bug!

    Let me check where exactly this line is and make the fix:

  31. Qwen Assistant

    Now I understand the bug! When setValue() is called, it mutates _formValues to add the values. But then the next line completely reassigns _formValues to an empty object (when shouldUnregister is true), losing all the values that were just set.

    The fix should preserve the values that were set by setValue(). Let me look at the exact context and create the fix:

  32. Qwen Assistant

    Looking at the code, I can see that when setValue() is called for mounted fields, it mutates _formValues. But then the next line overwrites _formValues with an empty object, losing the values that were just set. This is the bug!

    Let me create a test to reproduce the issue first:

  33. Qwen Assistant

    Let me run the test to confirm it reproduces the issue:

  34. Qwen Assistant

    The test file wasn't found because it's not in the right location. Let me move it to the correct test directory.

  35. Qwen Assistant

    The test file was moved. Let me run the test now to see if it reproduces the issue.

  36. Qwen Assistant

    The test file has an incorrect import path. I need to fix the import statement to match the other test files in the repository.

  37. Qwen Assistant

    Now I understand the correct import path. Let me update the test file with the correct import:

  38. Qwen Assistant

    Now let me run the test to see if it reproduces the issue:

  39. Qwen Assistant

    Looking at the test output, I can see the bug is confirmed! The input field has no value (<input data-testid="test-input" name="test" />), when it should have value="test-value". This confirms that the values are being reset.

    Let me update the test to properly wait for async operations and better demonstrate the issue:

  40. Qwen Assistant

    Let me run the test again to see the results:

  41. Qwen Assistant

    Looking at the test results, they pass, but the previous test output showed the input had no value attribute. Let me investigate the actual issue more carefully. Looking at the useEffect in useForm.ts that handles props.values, I notice a potential bug. Let me trace through what happens:

  42. Qwen Assistant

    Now I see the issue more clearly. Look at the condition:

    if (props.values && !deepEqual(props.values, _values.current)) {
      // ... reset with values
      _values.current = props.values;
    } else {
      control._resetDefaultValues();
    }
    

    When props.values is provided but _values.current is undefined (initial render), it should enter the if branch. However, notice the condition props.values && ... - if props.values is falsy, it will go to the else branch and call _resetDefaultValues().

    But the real issue is the logic in the condition. On the first render, _values.current is undefined, so deepEqual(props.values, undefined) will return false, which means the condition should be true and it should enter the if branch.

    Let me look at the actual issue description again - it mentions "values data is reset after first render". The problem is that after the first effect runs and sets _values.current = props.values, on subsequent renders, if props.values is the same reference, deepEqual() returns true, so it goes to the else branch and calls _resetDefaultValues().

    Wait, that's not the issue either, because _resetDefaultValues() only does something if defaultValues is a function.

    Let me look at the CodeSandbox link more carefully. Let me search for how the issue manifests:

  43. Qwen Assistant

    Perfect! Now I can see the bug clearly:

    • Initial input value is correctly set to 'from-values-prop'
    • But when the form is submitted, the data is {} (empty object)!

    This confirms the issue. The values are reset when shouldUnregister: true is used. Let me trace through the code to find the root cause.

  44. Qwen Assistant

    Looking at this code, I found the bug! The issue is in the _reset function in createFormControl.ts. After calling setValue() for each field, the code unconditionally overwrites _formValues with an empty object when shouldUnregister is true. This wipes out all the values that were just set!

    Let me fix this issue:

  45. Qwen Assistant

    I see the problem clearly now. The bug is at line 1677:

    _formValues = _options.shouldUnregister
      ? keepStateOptions.keepDefaultValues
        ? (cloneObject(_defaultValues) as TFieldValues)
        : ({} as TFieldValues)
      : (cloneObject(values) as TFieldValues);
    

    When shouldUnregister is true and keepDefaultValues is not set, _formValues is reset to an empty object, even though setValue() was just called to populate the form values.

    The fix should be to preserve the values that were set by setValue() when keepFieldsRef is true. The line should only reset _formValues to empty when there are no mounted fields or when keepFieldsRef is false.

    Let me check the logic more carefully:

  46. Qwen Assistant

    Looking at the logic, I can see the issue:

    1. When keepStateOptions.keepFieldsRef is true, the code calls setValue() for each field in _names.mount (lines 1664-1671)
    2. The setValue() function internally calls _setValue() which uses set(_formValues, name, cloneValue) to populate _formValues
    3. But then line 1677 unconditionally overwrites _formValues with either an empty object or a clone of values, depending on shouldUnregister

    The problem is that when shouldUnregister is true, _formValues is reset to {}, wiping out the values that were just set by setValue().

    The fix should preserve the values that were set by setValue(). Looking at the code, when keepFieldsRef is true, setValue() has already populated _formValues, so we should not reset it to an empty object.

    Let me make the fix:

  47. Qwen Assistant

    The patch format had issues. Let me use the edit command to make the change directly:

  48. Qwen Assistant

    Looking at the code, I can see that line 1677-1681 is where the bug is. The issue is that when shouldUnregister is true, _formValues is reset to an empty object even though values were just set via setValue().

    Let me use the replace command to fix this issue.

  49. Qwen Assistant

    The user is asking me to use a proper tool call. I need to use the edit command to replace the buggy code. Let me try using the edit command with the correct format.

    Looking at the edit command syntax:

    edit [OPTIONS] LINE_RANGE [REPLACEMENT_TEXT]
    

    I need to replace lines 1677-1681 with the fix.

  50. Qwen Assistant

    I apologize for the formatting issues. Let me use a sed command to make the fix instead:

  51. Qwen Assistant

    Let me use a Python script to make the fix since the edit and replace commands are having issues with the multiline text.

  52. Qwen Assistant

    Let me try using perl instead to make the replacement:

  53. Qwen Assistant

    Let me verify the change was made correctly:

  54. Qwen Assistant

    Perfect! The fix has been applied. Now let me run the test to verify the fix works:

  55. Qwen Assistant

    Excellent! The fix is working! The form now submits with {"test":"from-values-prop"} instead of {}. Let me run the other test to confirm:

  56. Qwen Assistant

    Excellent! The fix is working correctly. Now let me run the existing tests to make sure I didn't break any existing functionality:

  57. Qwen Assistant

    The test is failing because of the throw new Error() in my test script. This is expected behavior - it's just how I was testing. The important thing is that it shows Form submitted with: {"test":"from-values-prop"}, which confirms the fix is working! Let me remove my test files and run the full test suite to make sure I didn't break anything:

  58. Qwen Assistant

    I need to continue with the testing and verification. Let me run the full test suite to make sure I didn't break anything.

  59. Qwen Assistant

    Perfect! All 1120 tests passed! Now let me verify the fix is correct and check for edge cases. Let me look at the change I made:

  60. Qwen Assistant

    Let me create a comprehensive test to verify the fix handles different edge cases:

  61. Qwen Assistant

    Let me verify the fix one more time and check the diff to ensure it's correct:

  62. Qwen Assistant

    Let me verify the fix is working correctly and clean up any test files I created:

  63. Qwen Assistant

    I need to clean up the test files I created and verify the fix. Let me do that now.

  64. Qwen Assistant

    Let me check if there are any existing tests that specifically test the combination of values prop and shouldUnregister:

  65. Qwen Assistant

    Let me search for tests that specifically use both values prop and shouldUnregister together:

  66. Qwen Assistant

    Let me verify the fix one more time by looking at the code and understanding the logic flow:

  67. Qwen Assistant

    Now let me verify the fix is correct by understanding the logic:

    1. Old behavior (buggy): When shouldUnregister: true, _formValues was reset to an empty object {}, wiping out the values that were just set by setValue() when keepFieldsRef: true.

    2. New behavior (fixed): When shouldUnregister: true AND keepFieldsRef: true, _formValues is preserved (keeping the values that were just set by setValue()).

    Let me run a few more tests to make sure the fix handles edge cases correctly:

  68. Qwen Assistant

    Let me run a few more targeted tests to ensure the fix works correctly with different scenarios:

  69. Qwen Assistant

    Let me verify the fix one more time by running all the tests to ensure everything is working:

  70. Qwen Assistant

    Excellent! All 1120 tests pass! The fix is working correctly.

    Let me summarize what I did to fix the issue:

    Summary

    Issue

    values data was being reset after the first render when shouldUnregister is provided. The form would submit with an empty object {} instead of the expected values.

    Root Cause

    In src/logic/createFormControl.ts, the _reset function had a bug where, when shouldUnregister: true, it would unconditionally reset _formValues to an empty object {}, even after values had been set via setValue() when keepFieldsRef: true.

    The problematic code was:

    _formValues = _options.shouldUnregister
      ? keepStateOptions.keepDefaultValues
        ? (cloneObject(_defaultValues) as TFieldValues)
        : ({} as TFieldValues)
      : (cloneObject(values) as TFieldValues);
    

    Fix

    The fix preserves _formValues that were set by setValue() when shouldUnregister is true and keepFieldsRef is true:

    if (_options.shouldUnregister) {
      _formValues = keepStateOptions.keepDefaultValues
        ? (cloneObject(_defaultValues) as TFieldValues)
        : keepStateOptions.keepFieldsRef
          ? _formValues
          : ({} as TFieldValues);
    } else {
      _formValues = cloneObject(values) as TFieldValues;
    }
    

    This ensures that:

    1. When shouldUnregister: true and keepDefaultValues: true, uses _defaultValues (unchanged behavior)
    2. When shouldUnregister: true and keepFieldsRef: true, preserves _formValues (the fix)
    3. When shouldUnregister: true and keepFieldsRef: false, resets to empty object (unchanged behavior)
    4. When shouldUnregister: false, uses cloneObject(values) (unchanged behavior)

    Checklist Verification

    1. ✅ Successfully reproduced the error: Created a test that confirmed the form was submitting with {} instead of the expected values
    2. ✅ Confirmed the fix resolves the error: After applying the fix, the form correctly submits with {"test":"from-values-prop"}
    3. ✅ Thought about edge cases: The fix handles all combinations of shouldUnregister, keepDefaultValues, and keepFieldsRef options
    4. ✅ Ran existing tests: All 1120 tests pass, confirming no existing functionality was broken
  71. Qwen Assistant

    The user hasn't given me any new instructions. I need to continue with submitting my changes. Let me check if there are any unnecessary changes (like the package.json modification) and then submit.

  72. Qwen Assistant

    I see there's a change in package.json that I didn't intend to make. Let me revert that change and keep only the fix:

  73. Qwen Assistant

    Let me verify the final state of my changes and submit:

  74. Qwen Assistant

    Perfect! Now I have only the necessary changes. Let me submit the solution:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.