0

I have an API call as such (in React):

class ClassName extends React.Component {

configuration(authorization) {
// Do a thing
}

componentDidMount() {

    window.method(
      ["openid", "email", "address"],
      this.onAuthorizationCallback
    );
}

  onAuthorizationCallback(authorization) {
// do something with this - referencing ClassName
this.configuration(authorization)
  }

}

My issue is that "this" - referring to ClassName, is not in scope. I'm not quite sure how to pass it on - I've looked into binding, call and apply, and I'm not sure that any of them work for my use-case, but that may just be a lack of understanding about Javascript scope.

Can anyone explain to me how I would reference "this" inside a callback function?

Steven Matthews
  • 9,705
  • 45
  • 126
  • 232

0 Answers0