Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yungfu opened this issue Jun 15, 2022 · 7 comments

Comments

@yungfu
Copy link

yungfu commented Jun 15, 2022

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!

@ghost
Copy link

ghost commented Jun 15, 2022

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

@ghost ghost added the Needs: Triage 🔍 label Jun 15, 2022
@PeterWCox
Copy link

Thanks @yungfu - replacing the import statements worked for me.

PeterWCox added a commit to PeterWCox/sp-dev-fx-controls-react that referenced this issue Jun 26, 2022
Partial fix to the issue described here - see pnp#1235
@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Jun 28, 2022

I've tested out with the latest SPFx (1.15) and PnPJS - all look good.
The sample is attached.
Could you share your sample?
people-picker-1.zip

@yungfu
Copy link
Author

yungfu commented Jun 30, 2022

@AJIXuMuK - Add a ListPicker to webpart, and add import { ListPicker } from '@pnp/spfx-controls-react';.

<ListPicker
  context={props.spfxContext}  
/>
<PeoplePicker
    context={props.spfxContext}
    titleText={'Select people'}
    principalTypes={[PrincipalType.User]}
    ensureUser={true}
/>

In my project, I import ListPicker in another component file. They are all imported to one grandfather component. Finaly, I found that, any component that we can import { IconPicker or others } from '@pnp/spfx-controls-react'; directly will cause this issue.

@ekdegerman
Copy link

I get the same error when trying to upgrade to any version I tried <3.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

@michaelmaillot
Copy link
Collaborator

Hi @yungfu,

Since you've raised the issue, do you still have trouble and if it does, did you have the chance to retry with recent versions (>=3.10)?

@yungfu
Copy link
Author

yungfu commented Aug 8, 2023

I cannot reproduce this issue on 3.15. seems it has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants