question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read properties of undefined (reading 'User') to set PeoplePicker principalTypes

See original GitHub issue

Category

[ ] Enhancement

[ ] Bug

[x] Question

Version

Please specify what version of the library you are using: [ 3.7 & 3.8.0 ]

Expected / Desired Behavior / Question

 import {PeoplePicker, PrincipalType} from "@pnp/spfx-controls-react/lib/PeoplePicker";
 <PeoplePicker 
    context={props.spfxContext}
    titleText={'Select user'}
    ensureUser={true}
    principalTypes={[PrincipalType.User]}
    showHiddenInUI={false}
    resolveDelay={500}
/>

PeoplePicker always get

Uncaught TypeError: Cannot read properties of undefined (reading ‘User’)

But if I change the import statement to import {PeoplePicker, PrincipalType} from "@pnp/spfx-controls-react/lib/controls/peoplepicker"; The PeoplePicker rendered successfully.

The spfx version is 1.14, the pnp/sp version is 3.4.1, I also installed “rush-stack-compiler-4.2”(This is required by pnpjs v3). I am working on SharePoint Online with a mac mini.

I had make a similar demo with pnpjs v2 and rush-stack-compiler-3.9, the PeoplePicker worked well. But I cannot make sure this is caused by rush-stack-compiler.

So whether this is compatible with pnpjs v3, or I have missed something?

Thanks!

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
msftbot[bot]commented, Jun 15, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

0reactions
ekdegermancommented, Sep 7, 2022

I get the same error when trying to upgrade to any version I tried ❤️.10.0 from my current 3.4.1 with both SPFx 1.14.0 and SPFx 1.15.2. Changing the import statement as mentioned by the op helps for me too. Unfortunately 3.10.0 has another issue, as described in #1292

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spfx PNP people picker error for context
I have the same issue aswell. But a workaround that have worked before is <PeoplePicker context={this.props.
Read more >
PNP CustomCollectionFieldType - PeoplePicker can't find users
As the title states I am trying to use the PropertyFieldCollectionData in my SPFx Property Pane. But when I run the code and...
Read more >
PeoplePicker - @pnp/spfx-controls-react
Property Type Required Default context BaseComponentContext yes titleText string no groupName string no none
Read more >
How to blank a People Picker (PnP, spfx, react)
The problem is when I remove a user from any of the people pickers. The console gives me an error of Unable to...
Read more >
PnP People Picker Control In SharePoint Framework
Refer to this link to get the list of React controls for SPFx. You will see how to use the PnP People Picker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found