I'm having a React component that has both mgt-people
and mgt-people-picker
which takes props from its parent component. The idea is to update mgt-people
by selecting people from mgt-people-picker
, but it's not working. It did update in simply <div>{props.users}</div>
, so I think it might be an mgt component issue? I also tried making the users
a local state in the child component but it didn't work either.
My simplfied code is as below. All the users
variables are in type of string[]
parent:
function updateUsers(newUsers) {
setState({ users: newUsers });
}
render:
<ChildComponent users={this.state.users} updateUsers={this.updateUsers} />
child:
function updateUsers() {
props.updateUsers(newPeople);
}
peoplePicker.addEventListener('selectionChanged', updateUsers);
peoplePicker.selectUsersById(props.users);
render:
<div>{props.users}</div>
<mgt-people user-ids={props.users}></mgt-people>
<mgt-people-picker></mgt-people-picker>