Neel Shah
Neel Shah

Reputation: 36

How to populate value in People Picker

I am using People picker from @pnp/spfx-controls-react version 3.11.0 but there are no props available for value or selectedItems, but I need to populate user once a line item is removed from the list, on the people picker. Please find the code snippet below.

        <tbody>
                    {this.state.selectedApprover.map((element: any) => {
                      return (
                        <tr>
                          <td>{element.Count}</td>
                          <td>
                            <PeoplePicker
                              context={this.props.context}
                              personSelectionLimit={1}
                              onChange={(val: any[]) =>
                                this.ChangePeoplePickerValue(element.Count, val)
                              }
                              defaultSelectedUsers={element.DefaultUser}
                              principalTypes={[PrincipalType.User]}
                              resolveDelay={1000}
                            />
                          </td>
                          <td>
                            {element.Count == 1 ? (
                              ""
                            ) : (
                              <a href="#" className="removeRow text-danger">
                                <Icon
                                  iconName="SkypeCircleMinus"
                                  hidden={element.No === 1}
                                  onClick={() =>
                                    this.removeLineItem(element.Count)
                                  }
                                />
                              </a>
                            )}
                          </td>
                        </tr>
                      );
                    })}
                  </tbody>

I have tried doing the same using defaultSelectedUsers. But haven't found any solution.

Upvotes: 1

Views: 557

Answers (0)

Related Questions