Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
Warning: Can't perform a React state update on an unmounted component. Firebase Authentication

I'm using Firebase and Expo to authenticate the user information by registering and logging in, when I log in or register no warnings show up, but when I sign out from the app it returns the warning: Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. I narrowed down the problem to these three screens. I tried with many fixes with no results.

App.js

let unsubscribe;
export class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loaded: false,
    };
  }

  componentDidMount() {
    unsubscribe =  auth.onAuthStateChanged((user) => {
      if (!user) {
        this.setState({ loaded: true })
        this.setState({ loggedIn: false })
      } else {
        this.setState({ loaded: true })
        this.setState({ loggedIn: true })
      }
    })
  }

  componentWillUnmount() {
    unsubscribe()
  }

Account.js

export class Account extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loaded: false,
      signedIn: false,
      modalVisible: false,
    }
  }
  

        

  onSignOut = () => {
    auth
      .signOut()
  }

Register.js

export class Register extends Component {
    constructor(props) {
        super(props);
        this.state = {
            email: '',
            password: '',
            phoneNumber: '',
            loaded: false
        }
    }


    componentDidMount() {
        this.setState({loaded: true})
    }

    componentWillUnmount() {
        this.signUp()
    }


    singUp = async () => {
        const { phoneNumber, email, password } = this.state;
        const number = '+1' + phoneNumber
        try {
            const phoneProvider = new PhoneAuthProvider(auth);
            const verificationId = await phoneProvider.verifyPhoneNumber(
              number,
              recaptchaVerifier.current
            );
            this.props.navigation.navigate('VerifyPhoneNumber', {
                verificationId: verificationId,
                phoneNumber: number,
                signInWithPhoneNumber: false,
                email: email,
                password: password
            })
          } catch (err) {
            Alert.alert(
                'Alert',
                `${err}`
            )
          }
        }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!