MGT React PeoplePicker throws `Cannot use 'in' operator` when `selectedPeople` starts as null

I use the MGT React PeoplePicker with selectionMode='multiple' and pass an array of email addresses as selectedPeople. The picker renders with no names or pictures and throws: TypeError: Cannot use 'in' operator to search for 'groupTypes' in [email]. Passing Graph IDs instead of emails seems to be the documented usage, but emails should work too. What is wrong?

The error is not about emails vs IDs — it is a React state timing bug. selectedPeople was being populated after the initial render (e.g. via useState(null) then setGraphIds(others)), so on first render the picker received null and crashed when iterating over it. The fix, confirmed by the reporter: make sure the array is set before the picker first renders, so selectedPeople never starts as null. Initialize your state with the array (emails or IDs) up front, or do not render the picker until the array is populated.

Source: https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1644

Source: https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1644