NativeScript / NativeScript

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
https://nativescript.org
MIT License
24.26k stars 1.64k forks source link

Tabs component giving viewClass is not a constructor #9225

Closed AnthonyLenglet closed 3 years ago

AnthonyLenglet commented 3 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug

We released an update yesterday upgrading our app to NS7 after testing it for months, and seemingly out of the blue, after sending the app to the store, we're getting reports that the app is white screening when a tabs component is present, we've looked on our end and can now reproduce the issue: we're seeing the error:

JS: TypeError: viewClass is not a constructor
JS:     at ViewUtil.createView (file: node_modules/@nativescript/angular/fesm2015/nativescript-angular.js:2584:0)
JS:     at EmulatedRenderer.createElement (file: node_modules/@nativescript/angular/fesm2015/nativescript-angular.js:2784:0)
JS:     at EmulatedRenderer.createElement (file: node_modules/@nativescript/angular/fesm2015/nativescript-angular.js:3001:0)
JS:     at createElementNode (file: node_modules/@angular/core/fesm2015/core.js:6813:0)
JS:     at Module.ɵɵelementStart (file: node_modules/@angular/core/fesm2015/core.js:14542:0)

When looking at the source I do indeed see that its trying to create a ne viewClass() instance

createView(name) {
  const originalName = name;
  if (!isKnownView(name)) {
    name = 'ProxyViewContainer';
  }
  if (NativeScriptDebug.isLogEnabled()) {
    NativeScriptDebug.viewUtilLog(`Creating view: ${originalName} ${name}`);
  }
  const viewClass = getViewClass(name);
  ------> const view = new viewClass();
  const ngView = this.setNgViewExtensions(view, name);
  return ngView;
}

Things we've tried:

To Reproduce Add a Tabs component anywhere in the app

joeczar commented 3 years ago

I was having the same problem with Nativescript/core 8. I went back down to version 7.0.0 and it works with tabs. Hope that helps.

FunnyGhost commented 3 years ago

Same issue here. Seems like updating to NativeScript 8 is a no-go for now.

edusperoni commented 3 years ago

Tabs and BottomNavigation have been removed from NativeScript 8 (see https://github.com/NativeScript/NativeScript/blob/master/CHANGELOG.md#breaking-changes).

The main reason was that they were material components, so they added some material dependencies that were often outdated.

You can now replace them with @nativescript-community/ui-material-bottom-navigation and @nativescript-community/ui-material-tabs