nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
218 stars 80 forks source link

[BottomSheet] Angular 11 - Attempt to invoke virtual method 'androidx.fragment.app.FragmentTransaction' on a null object reference #211

Open bastienlemaitre opened 3 years ago

bastienlemaitre commented 3 years ago

Hi !

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I'm trying to open BottomSheet here: Component

@Component({
    selector: 'home',
    templateUrl: 'home.component.html'
})

export class HomeComponent implements OnInit, AfterViewInit {
    constructor(
        private _authService: AuthService,
        private _paymentService: PaymentService,
        private _biometricService: BiometricService,
        private _bottomSheetService: BottomSheetService, 
        private _viewContainerRef: ViewContainerRef,
    ) { }
    ngAfterViewInit(): void {
        const options: BottomSheetOptions = {
            viewContainerRef: this._viewContainerRef,
            context: ['Facebook', 'Google', 'Twitter']
        };

        this._bottomSheetService.show(SubscriptionComponent, options).subscribe(result => {
            console.log('Option selected:', result);
        });
    }

    ngOnInit() {
    }
}

Module :

@NgModule({
    imports: [
        NativeScriptModule,
        NativeScriptCommonModule,
        NativeScriptMaterialBottomSheetModule.forRoot(),
    ],
    exports: [],
    declarations: [HomeComponent, SubscriptionComponent],
    entryComponents : [SubscriptionComponent],
    providers: [],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class HomeModule { }

Child component:

@Component({
    selector: 'subscription',
    templateUrl: 'subscription.component.html',
    styleUrls: ['subscription.component.scss']
})

export class SubscriptionComponent implements OnInit {
    constructor() { }

    ngOnInit() { }
}

Error:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.fragment.app.FragmentTransaction androidx.fragment.app.FragmentTransaction.add(androidx.fragment.app.Fragment, java.lang.String)' on a null object reference
JS: _showNativeBottomSheet(file: node_modules\@nativescript-community\ui-material-bottomsheet\bottomsheet.android.js:119:0)
JS:     at showBottomSheet(file: node_modules\@nativescript-community\ui-material-bottomsheet\bottomsheet-common.js:89:0)
JS:     at (file: node_modules\@nativescript-community\ui-material-bottomsheet\angular\fesm2015\nativescript-community-ui-material-bottomsheet-angular.js:32:0)
JS:     at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.ZoneDelegate.invoke(file: node_modules\@nativescript\zone-js\zone-nativescript.js:388:0)
JS:     at push.../node_modules/@nativescript/zone-js/zone-nativescript.js.ZoneDelegate.invoke(file: node_modules\@nativescript\zone-js\zone-nativescript.js:387:0)
JS:     at push.../node_modules/@nativescript/zone-js/zone-nativesc...

Any idea ? Thanks !

bastienlemaitre commented 3 years ago

@farfromrefug ?