Skip to content

ArrayInput items with defaultValue from spec deletes the value due to StrictMode component in dev #262

@danonechik94

Description

@danonechik94

Issue
When the app is wrapped in the StrictMode component, React remounts the whole app on page load in dev mode. Thus, triggering the parentOnUnmount method of all components from the @gravity-ui/dynamic-forms package. This removes the default value in dev mode, but not in the resulting built application. This behavior sometimes results in drastically different behavior in dev and build envs. Here's the sample schema where this issue should be reproducible:

{
  "defaultValue": [{}],
  "type": "array",
  "minLength": 1,
  "items": {
    "type": "object",
    "properties": {
      "test": {
        "type": "string",
        "viewSpec": {
          "type": "base",
          "layout": "row",
          "layoutTitle": "Test"
        }
      }
    },
    "viewSpec": {
      "type": "base",
      "layout": "row",
      "layoutTitle": "Element"
    }
  },
  "viewSpec": {
    "type": "base",
    "layout": "accordeon",
    "layoutTitle": "Elements",
    "layoutOpen": true,
    "itemLabel": "Add element"
  }
}

Expected behavior
There is no difference in behaviour both with StrictMode and without it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions