Issue encountered in the attached mounted hook: "Issue: An AuthUI instance has already been created"

I am currently working on a single page application using Vuejs and leveraging Firebase for authentication. So far, I have successfully implemented sign in and sign up functionality with no issues. However, I have encountered a problem with Social Authentication.

Whenever I navigate to the sign-up page, the social buttons are displayed properly. But if I leave the page and return, I receive the following error:

Error in mounted hook: "Error: An AuthUI instance already exists

As a result, the social buttons fail to render.

Below is the snippet of code causing the issue:

mounted () {
  SocialAuth () {
    const uiConfig = {
      signInSuccessUrl: '/',
      signInOptions: [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.TwitterAuthProvider.PROVIDER_ID
      ]
    }

    const ui = new firebaseui.auth.AuthUI(firebase.auth())
    ui.start('#firebaseui-auth-container', uiConfig)
  }
}

Any assistance or guidance on resolving this matter would be greatly appreciated :)

Answer №1

Have you attempted to utilize

firebaseui.auth.AuthUI.getInstance()
in this way:

mounted () {
  SocialAuth () {
    const uiConfig = {
      signInSuccessUrl: '/',
      signInOptions: [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.TwitterAuthProvider.PROVIDER_ID
      ]
    }

    if(firebaseui.auth.AuthUI.getInstance()) {
      const ui = firebaseui.auth.AuthUI.getInstance()
      ui.start('#firebaseui-auth-container', uiConfig)
    } else {
      const ui = new firebaseui.auth.AuthUI(firebase.auth())
      ui.start('#firebaseui-auth-container', uiConfig)
    }
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to extract information from an array of strings containing the URL of an API

I am looking to extract data from an array that contains APIs, but the issue is that the number of APIs in the array varies. For example, some arrays may have 3 API addresses while others have just 2. { "name": "CR90 corvette", "m ...

Tips for stopping the textarea from moving around as you type and avoid it hitting the bottom of the page: Utilize JQuery and

As I type into the auto-sizing textarea, the text runs to the bottom of the page and causes it to dance uncontrollably with each key press. This forces me to constantly scroll down to see what's happening. How can I prevent this page dancing and keep ...

The component is converting a controlled text input to become uncontrolled

There's an error warning popping up, saying "A component is changing a controlled input of type text to be uncontrolled." I'm more used to class components, so functional components are new to me. All I did was: First, I set an initial state for ...

What steps can be taken to address issues with the counting system in a lootbox opening

I am currently developing a virtual loot box simulator and have encountered a challenging issue. My goal is to track the quantity of Normals, Legendaries, Epics, and Rares obtained by the user. However, I am facing a problem where instead of updating the c ...

Utilizing Vue's data variables to effectively link with methods and offer seamless functionality

I am encountering difficulty retrieving values from methods and parsing them to provide. How can I address this issue? methods: { onClickCategory: (value) => { return (this.catId = value); }, }, provide() { return { categor ...

Verify the presence of an email in the database utilizing a custom express-validator for node, express, and mysql

//Endpoint to update the user's email address. apiRouter.post('/update-email', [ check('newEmail') .isEmail().withMessage('Please enter a valid email address') .custom(newEmail=> { db.query(`SELECT user ...

Issues with functionality arise when cloning HTML divs using JQuery

VIDEO I created a feature where clicking a button allows users to duplicate a note div. However, the copied note does not function like the original - it's not draggable and changing the color of the copied note affects the original note's color. ...

Selecting an option from the knockout dropdown menu

I implemented a language dropdown in layout.chtml using knockout js. <select id="Language" class="styled-select" data-bind="value: Language,options: locale, value: selectedLocale, optionsText: 'name'"></select> var viewModel = th ...

Strategies for effectively managing numerous API requests

My current setup involves fetching about five API calls simultaneously. While it works at times, most of the time it results in a fetch error. Is there a way to prevent these errors from occurring when running the API calls? app.post("/movie/:movieN ...

Navigating Through Tabs in Bootstrap 4

I am currently working on a scrolling tab feature and encountering an issue. I am unable to click on the middle tabs as the scrolling movement is too abrupt when using the right button. How can I adjust the code to allow for a smoother scroll of the tabs? ...

Modifying the value of an element in an array of state variables

I currently have an array of objects stored as a state variable. My goal is to create a function that can modify a specific field within one of the objects. interface IItem{ id: string, selected: boolean } const [array, setArray] = useState<IItem[]&g ...

Tips for implementing validation in AngularJS

Could someone help me with AngularJS validation? I'm new to it and trying to make sure everything is correct. var app=angular.module('myApp',[]) app.controller('myController',function($scope){ $scope.clickMe = function(){ if($(& ...

Updating files in a Next.js project and automatically refreshing the page without the need to rerun 'npm run'

For a while now, I've been developing websites using a traditional LAMP stack with javascript (including jQuery) for the frontend. Recently, I decided to explore using javascript for the backend as well and started learning next.js. In the older meth ...

There was a TypeError that occurred because the object did not have the 'ajax' method available

When attempting to initialize the quoteResults Javascript function on my Wordpress site, I encounter the following error in my console: Uncaught TypeError: Object #<Object> has no method 'ajax' I have successfully utilized the code below ...

Is it possible to have Bootstrap 3 Navigation Tabs positioned at both the top and bottom of a

While working on a Bootstrap 3 website, I discovered that it is possible to have both a top nav-tab and bottom nav-tab section on the same page. These two distinct tab menus can control the display of the same tab content areas. However, I encountered an ...

What's stopping me from being able to "map" this collection of mongooses?

I have been attempting to map a group of user documents within mongoDB. Here's the code snippet I've written for this purpose. User.retrieveUsers = function() { return new Promise(async (resolve, reject) => { try { let ...

Creating a personalized Autocomplete feature using React Material-UI with the help of the renderInput method

I'm currently using a React Material UI Autocomplete component, similar to the one in the official documentation. For example, let's consider a list of countries: import * as React from 'react'; import Box from '@mui/material/Box& ...

Tips on how to indicate a checkbox as selected within an Angular controller

I'm in the process of creating a form for entering new service requests, as well as displaying and editing existing ones. One part of this form includes a list of labeled check-boxes that represent different countries. When an existing request is disp ...

The modal dialog from angular/material is unable to function properly when a shape on Google Maps is clicked

I have incorporated Google Maps into my application in order to showcase shapes (polygons/circles) and markers. To interact with Google Maps in Angular, I am utilizing the type definition "npm install --save @types/googlemaps". Upon clicking a shape, I nee ...

Begin by executing the initial commit task with Git through Gulp, followed by performing the

I am currently working on a project and I am trying to use gulp to commit and push to git. However, I am encountering an issue where the push task is not waiting for the commit task to complete before running... Can anyone assist me with this? I want to s ...