1

Microsoft official documentation- https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/use-sp-pnp-js-with-spfx-web-parts

In the PnPjsExample.tsx part, this part of code has:

const spCache = spfi(this._sp).using(Caching("session"));

I'm getting this following error:

"Type '"session"' has no properties in common with type 'ICachingProps'."

Don't know how to handle this error. Checked on spfx documentation on PnpJS but can't find it.

2
  • What version of SharePoint Framework are you using? You can find out by running npm list --depth=1 -g @microsoft/generator-sharepoint May 4, 2022 at 11:52
  • Hi Rob Thanks for your response, I'm using 1.14.0 as of my current SharePoint Framework version. May 4, 2022 at 12:23

1 Answer 1

2

I'm not that familiar with PnPJS caching so I'm not 100% sure this is the best/recommended fix, but this code change will get the sample working:

import { Caching, ICachingProps } from "@pnp/queryable";

// ...

const cacheProps: ICachingProps = {
  store: "session"
};
const spCache = spfi(this._sp).using(Caching(cacheProps));

I hope this helps.

1
  • Thank You Rob, it worked for me. May 5, 2022 at 4:53

Your Answer

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

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