Prevent double initializations of views

Published at

#ui5

This TIL is more than a year old. Some details may have changed.

It is best practice to not have the same view as both root view, and target of blank route. Using it for both, causes it to initialize twice.

JSON
"sap.ui5": {
    "flexEnabled": true,
    "rootView": {
      "viewName": "namespace.view.Root",
      "type": "XML",
      "async": true,
      "id": "appControl"
    },
    "routing": {
      "config": {
        "routerClass": "sap.m.routing.Router",
        "viewType": "XML",
        "viewPath": "namespace.view",
        "controlId": "appControl",
        "transition": "slide",
        "controlAggregation": "pages",
        "async": true,
        "bypassed": {
          "target": "notFound"
        }
      },
      "routes": [
        {
          "name": "appHome",
          "pattern": "",
          "target": "Home"
        }
      ],
      "targets": {
        "Home": {
          "viewName": "App",
          "viewId": "appView",
          "viewType": "XML",
          "viewLevel": 1  
        }
      }
    }
  }

Reference: Root View and Controller is instantiated 2 times #1746