I have two react components, an outer one called UserManagement and another one called UserList, which is used once as a subcomponent. I'm getting this familiar error message in my Chrome console:
Each child in an array or iterator should have a unique "key" prop. Check the render method of `UserList`.
Here's my UserList
's render method:
render() {
const { users, filteredUsers, filter } = this.props.userStore;
return (
<div>
{ filteredUsers.map(user=><div key={user.id}>{user.username}</div>) }
</div>
);
}
As you can see, there's nothing exotic here and the list does work as expected, but still there is the aforementioned error message. I also tried changing back the arrow functions to "oldschool" functions, btw.
This is the render method of my outer component UserManagement
where I use the UserList as seen above:
render() {
const { users, filteredUsers, filter } = this.props.userStore;
return (
<div>
<h4>User Management:</h4>
<UserList userStore={this.props.userStore} />
</div>
);
}