Skip to content

React.StrictMode throws error for all forms #412

Description

@JacobGalati

Environment

  • react-advanaced-form: 1.7.2

What

When running a create-react-app with React.StrictMode (the default for React 17) an Uncaught Invariant Viloation error is thrown for all form fields.

Current behavior

An error is thrown for the first form field and the field does not function.
Example:

Uncaught Invariant Violation: Cannot register field `userEmail`, 
the field with the provided name is already registered. 
Make sure the fields on the same level of `Form` or `Field.Group` have unique names.

Expected behavior

No error would be thrown and the field would function as expected.

Why

I think it is because strict mode renders components twice to detect code issues as mentioned here

How

Steps to reproduce the issue (ideally, link to the repository/sandbox).
Here is a Sandbox of the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions