- Qt 6.12
- Qt Qml
- QML Lint Warning and Errors
- Type is instantiated recursively
- Qt 6.12.0 Reference Documentation

# Type is instantiated recursively

This warning category is spelled `[type-instantiated-recursively]` by qmllint.

## Type can't be instantiated recursively

### What happened?

A component instantiated itself.

### Why is this bad?

The component needs itself to instantiate itself, creating an infinite loop. The QML runtime will error out on this component.

### Example

     // MyComponent.qml
     import QtQuick

     Item {
         MyComponent {}
     }

To fix this warning,

- Replace the problematic component with another one if it was a mistake.
- Postpone the instantiation to later, with Dynamic QML Object Creation from JavaScript for example.

     // MyComponent.qml
     import QtQuick

     Item {
         // solution 1: MyComponent was not needed here, use another type
         Item {}

         // solution 2: add a MyComponent property and set it later
         property MyComponent myChild
     }