pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
753 stars 304 forks source link

SPFx Context supplied to SPFx Behavior is null or undefined #3012

Closed RichardPo closed 5 months ago

RichardPo commented 5 months ago

Major Version

4.x

Minor Version Number

0.0

Target environment

SharePoint Framework

Additional environment details

I'm developing a client side web part.

Expected or Desired Behavior

I'm trying to setup graph with the SPFx context. I expect to get back an graphfi object when the context is not null or undefined.

Observed Behavior

While the context is not null and also not undefined, I get the error that the context is null or undefined. I debugged with console.log and saw that the context (this.context from the web part) is not null/undefined, it gives back the context object succesfully. Also, I downgraded to version 3 and it suddenly worked. But i need some functionality which is introduced in version 4. So downgrading is not an option.

Steps to Reproduce

Here is the code i'm running:

import {graphfi, SPFx} from "@pnp/graph";
this.graph = graphfi().using(SPFx(this.context));
bcameron1231 commented 5 months ago

Hi, thank you for finding this. It is indeed a bug. This issue is closed as we just deployed a Hotfix. Please find version 4.0.1 on npm.

github-actions[bot] commented 5 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.