Here is the people picker I am using within my component's Render:

<PeoplePicker context={this.props.context} titleText="" personSelectionLimit={1} groupName={""} showtooltip={true}  selectedItems={this._employeeName} showHiddenInUI={false} principalTypes={[PrincipalType.User]} resolveDelay={1000} ensureUser={true} disabled={false} defaultSelectedUsers={this.state.userEmail ? this.state.userEmail : []} />

I would suggest adding a selectedUsers value to your state, which you could set in your constructor's state initialization to this._employeeName, then you would change the selectedItems attribute in your PeoplePicker to selectedItems={this.state.selectedUsers}

At that point you would be able to use whatever logic you need within your component to call this.setState({selectedUsers: null})

  • I am using to selectedItems={this._employeeName} to get user profile properties of employee on resolve that is the problem I cannot change that Jan 17 '20 at 15:45
  • If you cannot change what selectedItems is bound to, then I think you are stuck. If you bind to a private variable instead of a state value, you'd have to completely re-instantiate the component to change the bound value.
    – willman
    Jan 17 '20 at 16:01

It should work to set this._employeeName to null and to reset user state you are using for defaultSelectedUsers this.state.userMail to []. By setting the state you trigger a rerendering while you deleted the current selected information by setting _employeeName to null or undefined

  • I am using this.setState({userEmail : ' ',}); this._employeeName(this.state.userEmail); Jan 17 '20 at 14:59
  • Does this work or is this the way you go but doesn't work? It could be to fast, so the second call will use old state values. If you want to work that way use setTimeout ---> this.setState({userEmail : ' '});setTimeout(() => this._employeeName(this.state.userEmail), 50);
    – MP_89
    Jan 17 '20 at 15:06
  • I was trying without settimeout but even after using settimeout it is not working Jan 17 '20 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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