Setting Root page in Ionic 4

My app is routing to the page based on the condition but the login page appears briefly before routing users to the profile page. How can I prevent that?

  initializeApp() {
    firebase.initializeApp(firebaseConfig);

    this.platform.ready().then(() => {
        const unsubscribe = firebase.auth().onAuthStateChanged( user => {
          if (!user) {
            this.router.navigateByUrl('login');
            unsubscribe();
            console.log('if !user', user);
          } else {
            this.router.navigateByUrl('profile');
            unsubscribe();
            console.log('if user', user);
          }
        });
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }

I think I may have resolved this by removing
{ path: ‘’, redirectTo: ‘login’, pathMatch: ‘full’ },

from AppRoutingModule.

If that’s not ideal please let me know.