Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging 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

    Interface

    No new interfaces are introduced.

    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. MiniMax Assistant

    Let me start by exploring the repository structure to understand what we're working with.

  3. MiniMax Assistant

    Let me look at the codesandbox example to understand the issue better:

  4. MiniMax Assistant

    Let me look at the _reset function more carefully:

  5. MiniMax Assistant

    Now let me look at _removeUnmounted:

  6. MiniMax Assistant

    Now let me look at the codesandbox example to understand what the user is doing:

  7. MiniMax Assistant

    Let me look at the codesandbox example. First let me check git logs to find a recent commit that may be related to this:

  8. MiniMax Assistant

    Let me try to reproduce the issue using a test similar to what's in the codesandbox example. Let me first check the structure of tests:

  9. MiniMax Assistant

    Now I have a sense of what tests look like. Let me create a test script that reproduces the issue from the codesandbox link:

  10. MiniMax Assistant

    Let me create a reproduction test file:

  11. MiniMax Assistant

    Let me create a simple test file to reproduce the issue:

  12. MiniMax Assistant

    I've successfully reproduced the issue. Let me now look more carefully at what's happening. Let me add some debugging to understand:

  13. MiniMax Assistant

    Let me check the git log for recent changes to _reset:

  14. MiniMax Assistant

    Let me check git blame for the _reset function:

  15. MiniMax Assistant

    Let me look at the _reset function more carefully to understand the bug:

  16. MiniMax Assistant

    Let me check the test that was added for the feature:

  17. MiniMax Assistant

    Let me look at the setValue function to understand its behavior:

  18. MiniMax Assistant

    Let me look at the test that was updated to understand the expected behavior:

  19. MiniMax Assistant

    Let me look at unregister:

  20. MiniMax Assistant

    Now let me look at the _reset function in detail to understand the data flow:

  21. MiniMax Assistant

    Let me check git blame for the specific lines around 1677:

  22. MiniMax Assistant

    Now let me check the api-extractor file to see the public interface:

  23. MiniMax Assistant

    Let me check generateWatchOutput:

  24. MiniMax Assistant

    Let me run the existing test to verify my understanding:

  25. MiniMax Assistant

    Let me check _resetDefaultValues:

  26. MiniMax Assistant

    Let me look at existing tests for keepFieldsRef + shouldUnregister: false:

  27. MiniMax Assistant

    Now I have a clear understanding of the bug. Let me implement the fix:

  28. MiniMax Assistant

    Now let me apply the fix:

  29. MiniMax Assistant

    Now let me run the reproduction test to verify the fix:

  30. MiniMax Assistant

    The test passes. Now let me run the existing tests to make sure I haven't broken anything:

  31. MiniMax Assistant

    All tests pass. Let me run the full test suite to be thorough:

  32. MiniMax Assistant

    All 1121 tests pass. Let me clean up my test file:

  33. MiniMax Assistant

    Let me now think about edge cases and verify my fix handles them well:

  34. MiniMax Assistant

    Hmm, test 2 failed. Let me look at it more carefully. The test expects submittedData to not include age because it's not mounted. But it seems age is included insubmittedData. Let me see:

  35. MiniMax Assistant

    Let me fix the test to have a proper unmounted field scenario:

  36. MiniMax Assistant

    All edge cases pass. Let me clean up and verify the final state:

  37. MiniMax Assistant

    Let me verify the change I made:

  38. MiniMax Assistant

    Let me also check if there's a similar issue with keepDefaultValues + keepFieldsRef:

  39. MiniMax Assistant

    That also works. Let me run the full test suite once more to make sure everything is passing:

  40. MiniMax Assistant

    All 1120 tests pass. Let me also verify the final state of my changes:

  41. MiniMax Assistant

    Let me restore the package.json since I didn't intend to modify it:

  42. MiniMax Assistant

    Now the only change is to src/logic/createFormControl.ts. Let me look at the current file once more to make sure the fix is correctly in place:

  43. MiniMax Assistant

    Let me run the full test suite one final time to confirm everything passes:

  44. MiniMax Assistant

    All 1120 tests pass.

    Now let me verify my understanding and reasoning by going through the checklist:

    1. If an error was reported in the issue description, I have successfully reproduced it.

      • Yes, I created a reproduction test that demonstrated the issue: when values is provided along with shouldUnregister: true, submitting the form resulted in submittedData = {} instead of the expected values.
    2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.

      • Yes, after applying my fix, the reproduction test now passes: submittedData = {firstName: 'bill', lastName: 'luo'}.
    3. I have thought about edge cases and made sure my fix handles them as well.

      • Yes, I tested several edge cases:
        • shouldUnregister + values (the main issue) - works
        • shouldUnregister + values + unmounted field - works (unmounted fields not in submission)
        • shouldUnregister + values + updates - works (values prop updates correctly)
        • values without shouldUnregister - works (existing behavior preserved)
        • shouldUnregister + values + keepDefaultValues - works
    4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

      • Yes, all 1120 existing tests pass.

    Now let me check the issue and verify my understanding is correct by re-reading the issue:

    The issue says:

    • values data is reset after first render, when shouldUnregister is provided
    • Steps: Simply submit a form
    • Expected: It is possible to successfully submit a form, when data is provided via values, and shouldUnregister: true option is set

    My fix:

    • In _reset, when shouldUnregister: true, keepFieldsRef: true, and keepDefaultValues: false, the previous code would set _formValues = {} after the loop had populated it via setValue calls.
    • My fix preserves _formValues (which was populated by the loop) in this specific case.

    This makes the form submission work correctly with the values prop and shouldUnregister: true.

    Let me submit:

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