3

Recently I noticed, SPFx Extension is updated from drop build to RC (release candidate) build, because of that one of my SPFx Extension Application Customizer stopped working. I went to SPFx Extension documents and most of the things are updated in document and following them I was able to make my application customizer working.

But earlier, there was page context (this.context.pageContext object) variable available which is now removed from RC. I was using page context to get Web absolute url to do some REST API data pull and using site logo property to get the logo.

Is there any alternative available to get the page context in RC or it is completely removed?

1 Answer 1

7

No its not removed or deprecated. Its working correctly . Just upgraded a sample and was able to work with the this.context object without any issue.

You need to ensure that you are using it inside the onInit() method because this event occurs after this.context is populated.

If you are using it before the onInit method, it will be undefined.

I have used the below sample code and it correctly logs the value in console (see following screenshot):

export default class TestappApplicationCustomizer
  extends BaseApplicationCustomizer<ITestappApplicationCustomizerProperties> {

  @override
  public onInit(): Promise<void> {

    console.log(this.context.pageContext.web.absoluteUrl);

    return Promise.resolve<void>();
  }
}

enter image description here

1
  • Yes you are right. Thanks. Although yesterday I checked the complete ApplicationCustomizerContext and ExtensionContext to see if it there or not. But was not able to find it. Now I realized its in BaseComponentContext not in two mentioned above. Sep 7, 2017 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.