Skip to content

reset() does not clear inputs wrapped with useController unless defaultValues are set #12883

Answered by BrendanC23
Best-Sardar asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think there's an easy way to handle all of the potential use-cases. For example, if the form contains these values, what should it be reset to?

{
    people: [
        {
            first: "John",
            last: "Smith",
        }
    ]
}

There are several alternatives that this could be reset() to.

{
    people: undefined,
}
{
    people: []
}
{
    people: [
        {
            first: undefined,
            last: undefined,
        }
    ]
}
{
    people: [
        {
            first: "",
            last: "",
        }
    ]
}

Setting all of the fields to undefined is problematic if a form is controlled and React will complain that controlled components are being changed …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@bluebill1049
Comment options

Answer selected by bluebill1049
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
waiting-up-vote Waiting for votes from the community. feature request request a feature to be added
3 participants
Converted from issue

This discussion was converted from issue #12882 on June 12, 2025 04:47.