Skip to content

Just Need Explanation on "this.removeAuthListener"  #12

@davidfufu

Description

@davidfufu

Hi There, just want to say that I love your guides, and I think they're more well explained and paced than most out there. I just had a question about the componentWIllMount() Code in App.js.

      this.removeAuthListener = app.auth().onAuthStateChanged((user) => {

I actually understand that it's a listener that listens for changes in authentication state. What I'm confused is how you're assigning to a ref and calling it later? I though that functions inside a component had to be bound in the constructor like "this.function.bind(this)", Could you refer me to reference for documentation for this?

  componentWillUnmount() {
  	console.log("Yo unmounting");
  	this.removeAuthListener();
    base.removeBinding(this.songsRef);
  }

And in the componentWillUnmount hook, you can call the function again, but the function was created or initiated in a "componentWillMount". Does that carry into the global scope of the entire component?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions